Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24

    Question Simple Question Searches do not give me an answer. DoCmd.GoToRecord acForm

    I have a large table that has 8 forms to input the data into the table. The problem I just realized that I have is that I am using these lines of code to close the form that the applicant is working on and go to the next form and go to the record that they were working on. The problem is what if I have two people entering data into the same table at the same time. So i think I need to specify what record to go to and thereby make sure that the data is being entered into the proper record. Any Ideas let me know.



    FYI it is a table for new applicants for the office. I think I need to declare a "where" statement and "look-up" or something, for the current record number before I close the form and then tell it to go to that record when it opens the next form. Am I somewhere in the ball park here? Or is there an acSame type expression.

    Private Sub NextPage2_Click()
    On Error GoTo NextPage2_Click_Err

    With CodeContextObject
    If (.Ready2 = False) Then
    Beep
    MsgBox "You must check the box to the left certifying the information on this page as accurate before you can go to the next page.", vbExclamation, "Must Verify Answers"
    End
    End If
    DoCmd.Close acForm, "Application2"
    DoCmd.OpenForm "Application3", acNormal, "", "[Ready2]=True", acEdit, acNormal
    DoCmd.GoToRecord acForm, "Application3", acLast
    ' What if there are two people entering an application at the same time, who's information goes where?
    Ready2 = False
    End With

    NextPage2_Click_Exit:
    Exit Sub

    NextPage2_Click_Err:
    MsgBox Error$
    Resume NextPage2_Click_Exit

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Does this work for you?

    BaldyWeb wherecondition

    You're using the argument now, with "[Ready2]=True". It sounds like using the ID would be more exact.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    I will give it a try and see what happens. Thank You excellent page. Also, to be honest with you I think my brain is fried, from working too many hours on this project. I have no Idea how I wrote that line of code, but it is working. The ready2 field is a boolean check box and for some reason it works.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Happy to help. What you have would work, but I thought wasn't filtering to the exact record. Post back if you're still stuck.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    Ok I am having some trouble.

    This is the line of code you suggested:

    DoCmd.OpenForm "SecondFormName", , , "FieldName = " & Me.ControlName

    This is what I have so far:

    DoCmd.OpenForm "SecondFormName", , , "ApplicantID = " & Me.ControlName


    I understand that the "&" is used for a string value and the "Me." refers to the object or "form" that I am currently on, But after that I am lost. I am trying to understand ControlName and I would think that it would refer to a filed ??? So do I put "Me.ApplicantID" in that place?

  6. #6
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    Tried this got an "Expected end of statement" error.

    DoCmd.GoToRecord acForm, "Application3", "ApplicantID =" Me.ApplicantID ( with the Me. highlighted)

  7. #7
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    Tried this it did not work. Not sure about the "," numbers.

    DoCmd.GoToRecord acForm, "Application3", , ApplicantID = Me.ApplicantID

  8. #8
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    Ok this does not work from Form "Application1" to form "Application2"

    DoCmd.GoToRecord acForm, "Application2", ApplicantID = Me.ApplicantID

    But this DOES work for going from Form "Application2" to Form "Application3"

    DoCmd.GoToRecord acForm, "Application3", ApplicantID = Me.ApplicantID

    Any idea as to why?

    O I also tried it this way

    DoCmd.GoToRecord acForm, "Application3", [ApplicantID] = Me.ApplicantID


    Here is the code so far

    Private Sub NextPage2_Click()
    On Error GoTo NextPage2_Click_Err

    Me.Refresh
    With CodeContextObject
    If (.Ready2 = False) Then
    Beep
    MsgBox "You must check the box to the left certifying the information on this page as accurate before you can go to the next page.", vbExclamation, "Must Verify Answers"
    End
    End If
    DoCmd.OpenForm "Application3", acNormal, "", "[Ready2]=True", acEdit, acNormal
    DoCmd.GoToRecord acForm, "Application3", ApplicantID = Me.ApplicantID
    Me.Ready2 = False
    DoCmd.Close acForm, "Application2"
    End With

    NextPage2_Click_Exit:
    Exit Sub

    NextPage2_Click_Err:
    MsgBox Error$
    Resume NextPage2_Click_Exit

    End Sub
    Last edited by MarkVenes; 11-30-2012 at 08:54 PM. Reason: Needed to add more info.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, to start at the first, yes, you'd use your name. This:

    DoCmd.OpenForm "SecondFormName", , , "ApplicantID = " & Me.ControlName

    Would be like

    DoCmd.OpenForm "Application2", , , "ApplicantID = " & Me.ApplicantID
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  10. #10
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    First, again thank you for your help it is much appreciated.

    Remembering that we were working with the GotoRecord portion: Maybe I am missing something.
    Are you telling me that in order to go to a specific record I need to;

    1. Alter my DoCmd.OpenForm line?

    ...... If so do I do this for each form or just the first form? Since the present GotoRecord worked when going from form 2 to form 3

    2. Remove the DoCmd.GotoRecord acForm line of code?

    ....... If so do I remove this line from every form as well?

    And this will solve my problem? If so, how do I alter the line so that it still retains the [Ready]=True ?

    This is my line presently: DoCmd.OpenForm "Application2", acNormal, "", "[Ready]=True", acEdit, acNormal

    Now, if I follow the logic in your reply, then is should look something line this? Based upon the current line.

    DoCmd.OpenForm "Application2", acNormal , "", "[Ready]=True AND "ApplicantID = " & Me.ApplicantID , acEdit, acNormal

    Not sure about combining expressions with the AND and how to do that argument.

  11. #11
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Well, my feeling is that it's better to get to the desired record in one step rather than two. You're really close with that last code. Take out the quotes right after the AND.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  12. #12
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    OK based on all the information you have given me this is what the Sub Looks like. BUT it does not work. When I go from Form Application1 to Form Application2 it starts a new record in the table. So, I am assuming I screwed up somewhere. Any ideas?


    Private Sub NEXTPAGE_Click()
    On Error GoTo NEXTPAGE_Click_Err

    With CodeContextObject
    If (.Ready = False) Then
    Beep
    MsgBox "You must check the box to the left certifying the information on this page as accurate before you can go to the next page.", vbExclamation, "Must Verify Answers"
    End
    End If
    DoCmd.OpenForm "Application2", acNormal, "", "[Ready]=True AND ApplicantID = " & Me.ApplicantID, acEdit, acNormal
    Me.Ready = False
    DoCmd.Close acForm, "Application1"
    End With

    NEXTPAGE_Click_Exit:
    Exit Sub

    NEXTPAGE_Click_Err:
    MsgBox Error$
    Resume NEXTPAGE_Click_Exit

    End Sub


    Let me Guess the AND should look like this instead And

  13. #13
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    Nope that was not it.

  14. #14
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Can you post the db here, or a representative sample?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  15. #15
    MarkVenes is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Nov 2012
    Location
    Lake Elsinore - Hell
    Posts
    24
    Ignore this message.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. deleteobject acform problem
    By pedrocat in forum Access
    Replies: 5
    Last Post: 11-07-2011, 07:22 AM
  2. DoCmd. Question
    By Trojnfn in forum Access
    Replies: 4
    Last Post: 09-30-2011, 04:51 PM
  3. Review/new answer to a question sub-form
    By vt800c in forum Forms
    Replies: 0
    Last Post: 10-18-2010, 12:04 PM
  4. Replies: 1
    Last Post: 10-01-2010, 04:44 AM
  5. (simple) Expressions give error message
    By P.Hofman in forum Forms
    Replies: 3
    Last Post: 01-21-2010, 01:57 AM

Tags for this Thread

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