I
insideout786
I have a table called tblCPA and Form called frmCPA. tblCPA has one
primary key called Date and foreign key called Location.
My problem is that I need to retrieve next record based on the date and
location on the form. for example if I am on the 1/1/2007 for New York,
I need to retrieve the next record which would be 1/2/2007 for New
York.
I used Do loop to find the record and setting all the form text fields
using me.date = rs!date.....etc. but that actually overwrites the
existing record and I get an error saying primary key already exist in
the table when I try to colse out of the form.
here is my example of me trying to retreive the record based on the
date and location
Function setForm()
Set db = CurrentDb
Set rs = db.OpenRecordset("tblcpa", dbOpenTable)
rs.MoveFirst
Do
If rs.Date = gbldate And rs.Location= gbllocation Then
Me.Date = rs!Date
Me.Location = rs!Location
Me.TotalDropOff = rs!TotalDropOff
Me.Bookmark = rs.Bookmark
Exit Do
End If
rs.MoveNext
Loop
End Function
Can someone help!!!!!!!
primary key called Date and foreign key called Location.
My problem is that I need to retrieve next record based on the date and
location on the form. for example if I am on the 1/1/2007 for New York,
I need to retrieve the next record which would be 1/2/2007 for New
York.
I used Do loop to find the record and setting all the form text fields
using me.date = rs!date.....etc. but that actually overwrites the
existing record and I get an error saying primary key already exist in
the table when I try to colse out of the form.
here is my example of me trying to retreive the record based on the
date and location
Function setForm()
Set db = CurrentDb
Set rs = db.OpenRecordset("tblcpa", dbOpenTable)
rs.MoveFirst
Do
If rs.Date = gbldate And rs.Location= gbllocation Then
Me.Date = rs!Date
Me.Location = rs!Location
Me.TotalDropOff = rs!TotalDropOff
Me.Bookmark = rs.Bookmark
Exit Do
End If
rs.MoveNext
Loop
End Function
Can someone help!!!!!!!