Results 1 to 3 of 3
  1. #1
    Join Date
    Aug 2002
    Posts
    4

    Unanswered: transfer data to another form

    [COLOR=darkblue] I'm (still) developing an application to dispatch vehicles into the city. On my main form (frmTripData) I have a combo box (cboPickMedNum) which links to a table of previous customers. The medical numbers are tied to a customer and we cannot alter them.

    If the dispatcher enters a medical number for a customer we do not currently have in our database, I'd like to open an entry form so that a new record can be made in the customer table. On this entry form (frmMembers), I have a text box for the medical number (tboMedNum).

    I am having the devils own time getting the value from [Forms]![frmTripdata].[cboPickMedNum] into [Forms]![frmMembers].[tboMedNum].

    I'm using the "On Not in list" event of cboPickMedNum with the following programming.

    ...
    Private Sub cboPickMedNum_NotInList(NewData As String, Response As Integer)
    ' Drop the value of cboPickMedNum into a global variable
    glbMedNum = Me!cboPickMedNum

    Dim intAnswer As Integer
    intAnswer = MsgBox("This Medical Number is not in the Members list. Do you want to add it?", vbYesNo, vbQuestion)

    If intAnswer = vbYes Then
    DoCmd.RunCommand acCmdUndo
    DoCmd.OpenForm "frmMembers", acNormal, , , acFormEdit, acDialog
    Response = acDataErrContinue
    ...

    End Sub

    Once the new form (frmMembers) is opened, the field tboMedNum has a default value = [gblMedNum]

    The form opens fine, but tboMedNum is blank.

    Any ideas?

  2. #2
    Join Date
    Jan 2003
    Location
    Dordrecht, The Netherlands
    Posts
    95
    I guess that you assign [glbMedNum] to the default value in the Form's property sheet. I'm almost sure this doesn't work: you cannot directly assign the value of a VBA variable to a form property this way.

    You can solve this by adding code in the Form_Load Sub of your form frmMembers, like this:

    'Begin of code sample
    Private Sub Form_Load

    Me.tboMedNum = glbMedNum

    End Sub
    'End of code sample

    This should do it.

    Ad Dieleman.

  3. #3
    Join Date
    Aug 2002
    Posts
    4
    Originally posted by Ad Dieleman
    I guess that you assign [glbMedNum] to the default value in the Form's property sheet. I'm almost sure this doesn't work: you cannot directly assign the value of a VBA variable to a form property this way.

    You can solve this by adding code in the Form_Load Sub of your form frmMembers, like this:

    'Begin of code sample
    Private Sub Form_Load

    Me.tboMedNum = glbMedNum

    End Sub
    'End of code sample

    This should do it.

    Ad Dieleman.

    That did it. For my egos sake, I was hoping for a much longer and more complex answer.... But I'll take whatever works.

    Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •