navigation problems

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I have a database with two forms that are based on one table. To get from
one form to the next, I have created a command button at the bottom of form 1
to open up form 2. I am having problems navigating through my forms after
the first record has been entered. When I enter record 2 and click on the
open form 2 button, the 2nd form opens up to the first record, but I want it
to open up to the current record (i.e., record 2). What do I need to do in
order to achieve this?
 
Hi,

I have a database with two forms that are based on one table. To get from
one form to the next, I have created a command button at the bottom of form 1
to open up form 2. I am having problems navigating through my forms after
the first record has been entered. When I enter record 2 and click on the
open form 2 button, the 2nd form opens up to the first record, but I want it
to open up to the current record (i.e., record 2). What do I need to do in
order to achieve this?

You need to tell it to do so.
Use the Where argument of the OpenForm method.

DoCmd.OpenForm "form2", , ,"[RecordID] = " & Me![RecordID]

The above assumes a Prime Key field named [RecordID] and that it is a
Number datatype.
Change RecordID to what ever your actual prime key field is.

If the Prime Key field is Text datatype, use:
"[RecordID] = '" & Me![RecordID] & "'"
 
Remove the button from Form 1. Make sure the wizard button in your toolbox
is turned on, then put a new button on the form. You'll find the wizard
offers you the option to open the second form and display only selected
data. Follow the directions, and Access will write the code for you.
 
Hello Fred,

Thank you for your reply. I did what I think it was you suggested, but it
did not work. When I clicked on the 'Page 2(Form 2)' command button at the
end of Form 1, I received an error stating that I can't go to the specified
record and the record selector was still at the first record on page 2. Then
when I attempted to move the record selector to the current record, I got an
error message (#3022), saying that the changes requested to the table were
not successful b/c they would create duplicate values in the index, primary
key, or relationship.

Here is my code--perhaps this code was not placed in the right place?

Private Sub T1_Page2_Click()
On Error GoTo Err_T1_Page2_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "T1_1WkFU(Page 2)"
DoCmd.OpenForm stDocName, , , "[ID] = " & Me![ID]

Exit_T1_Page2_Click:
Exit Sub

Err_T1_Page2_Click:
MsgBox Err.Description
Resume Exit_T1_Page2_Click

End Sub

Thanks in advance for any suggestions/corrections you may have.

Tracy

--
Tracy


fredg said:
Hi,

I have a database with two forms that are based on one table. To get from
one form to the next, I have created a command button at the bottom of form 1
to open up form 2. I am having problems navigating through my forms after
the first record has been entered. When I enter record 2 and click on the
open form 2 button, the 2nd form opens up to the first record, but I want it
to open up to the current record (i.e., record 2). What do I need to do in
order to achieve this?

You need to tell it to do so.
Use the Where argument of the OpenForm method.

DoCmd.OpenForm "form2", , ,"[RecordID] = " & Me![RecordID]

The above assumes a Prime Key field named [RecordID] and that it is a
Number datatype.
Change RecordID to what ever your actual prime key field is.

If the Prime Key field is Text datatype, use:
"[RecordID] = '" & Me![RecordID] & "'"
 
Back
Top