L
Lee
I'm sorry I keep asking about this but I'm still having
trouble getting this to work. All I want to do is to use
a form to find a record in one table, locate
the 'matching' record in another table (via a common
control called 'Tracking Number') and display that second
matching record in a form. Easy-peasy, lemon-squeezy?
Nope, not for me it ain't! Here's my revised code. Am I
using the wrong type of recordset? If you can help,
please can you spell it out to me why it's not working!
Many thanks...
Dim db As Database
Dim rst As Recordset
Dim rstMain As Recordset
Dim frm As Form
Dim varGoTo As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("Candidates")
If IsNull(Me!GoToRecord) Then
MsgBox "First enter a name to look up!",
vbExclamation, "Oops!"
Me!GoToRecord.SetFocus
Else
rst.FindFirst "[Surname]=" & "'" & Me!GoToRecord & "'"
End If
If rst.NoMatch Then
MsgBox "No records match the Surname provided.
Try again.", vbInformation, "No records found"
Else
rst.Bookmark = Me.Bookmark
varGoTo = Me.[Tracking Number]
Set rstMain = db.OpenRecordset("Centres")
Set frm = Forms("Data Input Screen")
rstMain.FindFirst "[Tracking Number]=" & varGoTo
frm.Bookmark = rstMain.Bookmark
End If
rst.Close
rstMain.Close
I do hope you guys can help with this before I lose ALL
my hair over this.
Regards
Lee
trouble getting this to work. All I want to do is to use
a form to find a record in one table, locate
the 'matching' record in another table (via a common
control called 'Tracking Number') and display that second
matching record in a form. Easy-peasy, lemon-squeezy?
Nope, not for me it ain't! Here's my revised code. Am I
using the wrong type of recordset? If you can help,
please can you spell it out to me why it's not working!
Many thanks...
Dim db As Database
Dim rst As Recordset
Dim rstMain As Recordset
Dim frm As Form
Dim varGoTo As Variant
Set db = CurrentDb
Set rst = db.OpenRecordset("Candidates")
If IsNull(Me!GoToRecord) Then
MsgBox "First enter a name to look up!",
vbExclamation, "Oops!"
Me!GoToRecord.SetFocus
Else
rst.FindFirst "[Surname]=" & "'" & Me!GoToRecord & "'"
End If
If rst.NoMatch Then
MsgBox "No records match the Surname provided.
Try again.", vbInformation, "No records found"
Else
rst.Bookmark = Me.Bookmark
varGoTo = Me.[Tracking Number]
Set rstMain = db.OpenRecordset("Centres")
Set frm = Forms("Data Input Screen")
rstMain.FindFirst "[Tracking Number]=" & varGoTo
frm.Bookmark = rstMain.Bookmark
End If
rst.Close
rstMain.Close
I do hope you guys can help with this before I lose ALL
my hair over this.
Regards
Lee