Problem with GoToRecord

S

Steve

Hello! Here's the deal: I have a database with multiple
forms, but for the sake of brevity, let's say I have only
2. I want to move from FormB back to FormA, and I have a
nice little button that does that. However, if I'm on
Record 2 of FormB, I want to go to Record 2 of FormA, if
I'm on Record 3 on FormB, then I want Record 3 of FormA,
etc. Essentially, I want the current record. The problem
is that something is not right with GoToRecord - when I
click the button on FormB, I always seem to end up on
Record 1 of FormA, no matter what Record of FormB I am
working with. I'd appreciate any help in fixing this, and
if it helps, here's the code for the event (one more
thing - the names of the forms for this database
are "Insurance Information Form" and "WinLife Patient
Profile Form," as you'll obviously see):

Private Sub Back_to_Insurance_Info_Command_Click()
On Error GoTo Err_Back_to_Insurance_Info_Command_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim lcurrentrecnum As Long


stDocName = "Insurance Information Form"
lcurrentrecnum = Forms![WinLife Patient Profile
Form].CurrentRecord

DoCmd.Close ObjectType:=acForm, _
ObjectName:="WinLife Patient Profile Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord [ObjectType As acDataForm = acForm],
[stDocName], [Record As AcRecord = acGoTo],
[lcurrentrecnum]

Exit_Back_to_Insurance_Info_Command_Clic:
Exit Sub

Err_Back_to_Insurance_Info_Command_Click:

DoCmd.Close ObjectType:=acForm, _
ObjectName:="WinLife Patient Profile Form"
Resume Exit_Back_to_Insurance_Info_Command_Clic

End Sub
 
W

William Taylor

use the on current event of form B and use the find method of form A's
recordset, refer to bookmark, and find in help for more info and examples
 
S

Steve

I'm not exactly sure what you mean - right now, it's an on-
click event (a button). Also, I'm not familiar with the
syntax for the other operations, and I've tried to follow
the help examples with no success (ie, I followed them
just fine, but nothing works!). Could you clarify?

-----Original Message-----
use the on current event of form B and use the find method of form A's
recordset, refer to bookmark, and find in help for more info and examples
Steve said:
Hello! Here's the deal: I have a database with multiple
forms, but for the sake of brevity, let's say I have only
2. I want to move from FormB back to FormA, and I have a
nice little button that does that. However, if I'm on
Record 2 of FormB, I want to go to Record 2 of FormA, if
I'm on Record 3 on FormB, then I want Record 3 of FormA,
etc. Essentially, I want the current record. The problem
is that something is not right with GoToRecord - when I
click the button on FormB, I always seem to end up on
Record 1 of FormA, no matter what Record of FormB I am
working with. I'd appreciate any help in fixing this, and
if it helps, here's the code for the event (one more
thing - the names of the forms for this database
are "Insurance Information Form" and "WinLife Patient
Profile Form," as you'll obviously see):

Private Sub Back_to_Insurance_Info_Command_Click()
On Error GoTo Err_Back_to_Insurance_Info_Command_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim lcurrentrecnum As Long


stDocName = "Insurance Information Form"
lcurrentrecnum = Forms![WinLife Patient Profile
Form].CurrentRecord

DoCmd.Close ObjectType:=acForm, _
ObjectName:="WinLife Patient Profile Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord [ObjectType As acDataForm = acForm],
[stDocName], [Record As AcRecord = acGoTo],
[lcurrentrecnum]

Exit_Back_to_Insurance_Info_Command_Clic:
Exit Sub

Err_Back_to_Insurance_Info_Command_Click:

DoCmd.Close ObjectType:=acForm, _
ObjectName:="WinLife Patient Profile Form"
Resume Exit_Back_to_Insurance_Info_Command_Clic

End Sub


.
 
W

William Taylor

Try this:
forms!formB.recordset.findfirst "[FieldToSyncInfo] = " & me!fieldWithInfo
Steve said:
I'm not exactly sure what you mean - right now, it's an on-
click event (a button). Also, I'm not familiar with the
syntax for the other operations, and I've tried to follow
the help examples with no success (ie, I followed them
just fine, but nothing works!). Could you clarify?

-----Original Message-----
use the on current event of form B and use the find method of form A's
recordset, refer to bookmark, and find in help for more info and examples
Steve said:
Hello! Here's the deal: I have a database with multiple
forms, but for the sake of brevity, let's say I have only
2. I want to move from FormB back to FormA, and I have a
nice little button that does that. However, if I'm on
Record 2 of FormB, I want to go to Record 2 of FormA, if
I'm on Record 3 on FormB, then I want Record 3 of FormA,
etc. Essentially, I want the current record. The problem
is that something is not right with GoToRecord - when I
click the button on FormB, I always seem to end up on
Record 1 of FormA, no matter what Record of FormB I am
working with. I'd appreciate any help in fixing this, and
if it helps, here's the code for the event (one more
thing - the names of the forms for this database
are "Insurance Information Form" and "WinLife Patient
Profile Form," as you'll obviously see):

Private Sub Back_to_Insurance_Info_Command_Click()
On Error GoTo Err_Back_to_Insurance_Info_Command_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim lcurrentrecnum As Long


stDocName = "Insurance Information Form"
lcurrentrecnum = Forms![WinLife Patient Profile
Form].CurrentRecord

DoCmd.Close ObjectType:=acForm, _
ObjectName:="WinLife Patient Profile Form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.GoToRecord [ObjectType As acDataForm = acForm],
[stDocName], [Record As AcRecord = acGoTo],
[lcurrentrecnum]

Exit_Back_to_Insurance_Info_Command_Clic:
Exit Sub

Err_Back_to_Insurance_Info_Command_Click:

DoCmd.Close ObjectType:=acForm, _
ObjectName:="WinLife Patient Profile Form"
Resume Exit_Back_to_Insurance_Info_Command_Clic

End Sub


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top