Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    control1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    16

    Question Jump to Record

    Hi All - wondering if anyone can help.



    I've got a form used for data input. I want a user to be able to input the data on Form 1, and then click a button to "Save and Open" the record in another form (Form 2) (which contains different options/data).

    At present I've got the button on the form, and when a user clicks the 'Save and Open' button - it loads my Form 2 - but doesn't jump to that record.

    The code i have is:

    Code:
     Private Sub btnSaveOpen_Click()
    DoCmd.Save
    DoCmd.OpenForm "frmViewIssue", , , "[ID] = " & Me.ID
    Me.Requery
    End Sub
    Can anyone help?

    Many thanks,

    Leigh

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    This is how to do it.
    providing ID is the name of the textbox in me.ID
    This works everytime.
    me.requery is not needed.

  3. #3
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Quote Originally Posted by control1 View Post
    Hi All - wondering if anyone can help.

    I've got a form used for data input. I want a user to be able to input the data on Form 1, and then click a button to "Save and Open" the record in another form (Form 2) (which contains different options/data).

    At present I've got the button on the form, and when a user clicks the 'Save and Open' button - it loads my Form 2 - but doesn't jump to that record.

    The code i have is:

    Code:
     Private Sub btnSaveOpen_Click()
    DoCmd.Save
    DoCmd.OpenForm "frmViewIssue", , , "[ID] = " & Me.ID
    Me.Requery
    End Sub
    Can anyone help?

    Many thanks,

    Leigh
    Is Me.ID holding a number or text

    What message do you get if you use:
    Code:
     Private Sub btnSaveOpen_Click()DoCmd.Save
    DoCmd.OpenForm "frmViewIssue", , , "[ID] = " & Me.ID
    Msgbox Me.ID
    Me.Requery End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  4. #4
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Not sure it matters but take space out after the last comma? And as others asked, is that ID text or numeric?

    DoCmd.OpenForm "frmViewIssue", , ,"[ID] = " & Me.ID

  5. #5
    control1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    16
    Thanks to all replies. I've tried taking that out Bulzie but still not working.
    No error message shown Bob Fitz.

    It's an Auto Number...

    Here's the field info. It basically adds "ECC1" as a prefix to the ID.
    Click image for larger version. 

Name:	field.png 
Views:	9 
Size:	3.3 KB 
ID:	28136

    When I press the button it opens the form, and just displays "New" on the new form.....

    Click image for larger version. 

Name:	Step1.png 
Views:	9 
Size:	6.3 KB 
ID:	28137

    Click image for larger version. 

Name:	Step2.png 
Views:	9 
Size:	11.1 KB 
ID:	28138

  6. #6
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    If the value of Me.ID in the top form 189 or ECC189?

  7. #7
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I didn't expect you to get an Error Message.
    The inclusion of the line:
    Code:
    Msgbox Me.ID
    will make a message box open and display the value of Me.ID
    So I ask again, What message do you get?
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  8. #8
    control1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    16
    Quote Originally Posted by Bulzie View Post
    If the value of Me.ID in the top form 189 or ECC189?
    It's actually "89". The AutoNumber format adds "ECC1" to the record.

  9. #9
    control1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    16
    Quote Originally Posted by Bob Fitz View Post
    I didn't expect you to get an Error Message.
    The inclusion of the line:
    Code:
    Msgbox Me.ID
    will make a message box open and display the value of Me.ID
    So I ask again, What message do you get?
    Apologies, I see now.

    The message box shows as "91" (I'd created a few new record)

    Click image for larger version. 

Name:	91.png 
Views:	9 
Size:	22.8 KB 
ID:	28139

  10. #10
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    Perhaps something like:
    Code:
    DoCmd.OpenForm "frmViewIssue", , , "[ID] = """ECC1" & Me.ID & """
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  11. #11
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    In your table the ID field is 91 or ECC91?

  12. #12
    control1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    16
    Quote Originally Posted by Bob Fitz View Post
    Perhaps something like:
    Code:
    DoCmd.OpenForm "frmViewIssue", , , "[ID] = """ECC1" & Me.ID & """

    Thanks for your suggestion Bob. When I enter this, I get a compile error message - probably something really simple, but as a novice I can't see what...!
    Click image for larger version. 

Name:	compile.png 
Views:	8 
Size:	9.7 KB 
ID:	28140

  13. #13
    control1 is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    16
    Quote Originally Posted by Bulzie View Post
    In your table the ID field is 91 or ECC91?
    It's strange. It shows as "ECC191" if you was to look at it, but if you click that field it shows it as 91..

    Click image for larger version. 

Name:	2017-04-05 15_57_09-Access - Event Control Log1 _ Database- T__RX_LANC_SCI_FEST_LSF 2017_Event C.png 
Views:	9 
Size:	1.5 KB 
ID:	28141

  14. #14
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Do you have to put that ECC as format on that field in the table? Can you just do that format on your Form or Report field, not the table itself?

  15. #15
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 7 32bit Access 2013
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,610
    I have tested the following and it works for me
    Use this code to open the second form
    Code:
    Private Sub btnSaveOpen_Click()DoCmd.Save
        DoCmd.OpenForm "frmViewIssue", , , , , , Me.ID
    End Sub
    Put this code in the On Open event of your form called "frmViewIssue"
    Code:
    Private Sub Form_Open(Cancel As Integer)
    
      If Not IsNull(Me.OpenArgs) Then
           Me.Filter = "[ID] = " & Me.OpenArgs
           Me.FilterOn = True
      End If
    
    End Sub
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

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

Similar Threads

  1. Replies: 2
    Last Post: 10-09-2016, 06:46 AM
  2. How to Open form and jump to certain record?
    By behnam in forum Programming
    Replies: 3
    Last Post: 06-05-2014, 08:45 AM
  3. Using a Combo Box to jump to a record
    By Access_Novice in forum Forms
    Replies: 3
    Last Post: 11-19-2013, 04:14 PM
  4. Text Box - Jump to Record
    By drow in forum Forms
    Replies: 5
    Last Post: 03-12-2012, 11:25 PM
  5. How to jump on a new record when forms open?
    By braveali in forum Programming
    Replies: 3
    Last Post: 02-21-2012, 08:17 AM

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