Results 1 to 4 of 4
  1. #1
    slaterino is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2009
    Posts
    25

    Trying to take values from 1 form to another

    I am having problems taking values from 1 form to another. I have used this exact code before and never had any problems. However, it seems that it is not working for this particular form and I need some help figuring out why.

    I have an IF clause within my source form. At the moment, this is simply choosing whether the destination form opens to a current record or a new record. When it opens to a new record I want to take values from my combo boxes into the destination form so that this data will then be used in the new record.

    This is the simple code:

    Private Sub cmdEnterResults_Click()



    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frm_monitoring_responses"

    If (Nz(DLookup("URN", "tblSrvRspns", "URN = " & Me!cboURN), 0) = 0) Then

    DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormAdd

    Forms!frm_monitoring_search.Controls!cboURN = Forms!frm_monitoring_responses.Controls!cURN
    Forms!frm_monitoring_search.Controls!cboSrvID = Forms!frm_monitoring_responses.Controls!cSrvID

    Else

    DoCmd.OpenForm stDocName, , , stLinkCriteria

    End If

    End Sub

    When it opens to a new record it is doing so with 0 and 0 in the cURN and cSrvID fields. Is there any reason why it would not enter these details into the destination form.

    FYI, cURN and cSrvID are both text boxes bound to the record. It is however possible to enter values manually into these boxes so I don't know why it will not bring the values in from the source form. Any ideas?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    The syntax for those equates is:
    Destination = Source
    I believe you have it backwards for what you want to accomplish.

  3. #3
    slaterino is offline Novice
    Windows XP Access 2003
    Join Date
    Apr 2009
    Posts
    25
    RG,
    I've had to edit my reply. You are absolutely right. Sorry, it took me a little bit of time to actually catch on to the fact that they were in reverse. Apologies, and thanks!!!

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad to hear you got it sorted.

Please reply to this thread with any new information or opinions.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums