Results 1 to 5 of 5
  1. #1
    paulw is offline Novice
    Windows Vista Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1

    Smile passing values between forms

    Hi guys, i know you've had this question before and i've tried to follow the previous posts but still cant get my forms working properly.

    my problem.

    I have a main form (frmqrytblpersonnel) where name, surname, branch, region are added. this works fine. i have then put a button on the form which opens up another form based on a query (frmqrytblcaecapq).

    I have a unique id in form 1 called tblpersonnelid. i need to take the value from tblpersonnelid and put it in the same field in the other form. this is what ive done from the previous posts:

    Private Sub Command25_Click()
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frmqrytblcaecapq"


    stLinkCriteria = "frmqrytblcaecapq_tblpersonnelid =" & "'" & Me!tblpersonnelid & "'"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec
    Form_frmqrytblcaecapq.tblpersonnelid = Form_frmqrytblpersonnel.tblpersonnelid
    End Sub

    but it doesnt work....

    any thoughts on how to get this begginer going?

  2. #2
    nicknameoscar is offline Advanced Beginner
    Windows XP Access 2000
    Join Date
    Apr 2011
    Location
    Earlysville, VA
    Posts
    91
    I don't use Access 2010 so maybe something changed but shouldn't

    Form_frmqrytblcaecapq.tblpersonnelid = Form_frmqrytblpersonnel.tblpersonnelid


    be written like this:

    Forms!frmqrytblcaecapq.tblpersonnelid = Forms!frmqrytblpersonnel.tblpersonnelid

    or maybe this:

    Forms!frmqrytblcaecapq!tblpersonnelid = Forms!frmqrytblpersonnel!tblpersonnelid

  3. #3
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Actually, if the field is tblpersonnelid it should be:

    stLinkCriteria = "tblpersonnelid =" & "'" & Me!tblpersonnelid & "'"

  4. #4
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    And I, personally, would use:

    stLinkCriteria = "tblpersonnelid =" & Chr(34) & Me!tblpersonnelid & Chr(34)

  5. #5
    boblarson is offline --------
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2011
    Posts
    1,272
    Oh, and don't use this syntax for referring to a form:

    Form_frmqrytblcaecapq.tblpersonnelid = Form_frmqrytblpersonnel.tblpersonnelid

    as the Form_ part can cause unintended side effects. Use the forms collection like nicknameoscar said:

    Forms!frmqrytblcaecapq.tblpersonnelid ...etc.

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

Similar Threads

  1. Passing Data Between Forms
    By exeTrix in forum Programming
    Replies: 3
    Last Post: 04-05-2011, 01:06 PM
  2. PASSING Values between Forms
    By chhinckley in forum Programming
    Replies: 1
    Last Post: 08-27-2010, 10:19 AM
  3. Passing variable values to Stored Procedure
    By rodrigopcnet in forum Access
    Replies: 1
    Last Post: 04-14-2010, 10:35 AM
  4. Replies: 3
    Last Post: 06-02-2009, 09:51 AM
  5. Passing Values
    By dromorkid in forum Forms
    Replies: 0
    Last Post: 11-25-2008, 05:04 PM

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