Recordset Clone

C

Confused

I have a dialog form "GotoRecordDialog" When I select the records on it I
want the record on "CLECS2MainForm" to go to the same record. It says
invalid syntax on this part of the code below rst.FindFirst "CLEC_ID = " &
List2 I changed quotes around where I don't get an error, but it never
changes the records.

Private Sub Show_Record_Click()

Dim rst As DAO.Recordset

Set rst = Forms!CLECS2MainForm.RecordsetClone

Forms!CLECS2MainForm.Bookmark = rst.Bookmark

rst.FindFirst "CLEC_ID = " & List2

DoCmd.Close acForm, "GoToREcordDialog"
 
B

Beetle

Well, for starters, you don't set the bookmark until after you
find a matching record. Assuming that the bound column of
List2 stores the same data type as CLEC_ID, and if those values
are numeric, the code might look like;

Private Sub Show_Record_Click()

With Forms!CLECS2MainForm.RecordsetClone
.FindFirst "CLEC_ID=" & Me!List2
If Not .NoMatch Then
Forms!CLECS2MainForm.Bookmark = .Bookmark
End With

DoCmd.Close acForm, "GoToREcordDialog

End Sub

If the values in question are text, then you'll need to place
additional quotes in the .FindFirst line;

.FindFirst "CLEC_ID=""" & Me!List2 & """"
 
C

Confused

I tried this to include the End if because I was getting "end with without
block if" error. I still get syntax error (missing operator) CLEC ID is a
number field. Any idea?

With Forms!CLECS2MainForm.RecordsetClone
.FindFirst "CLEC_ID=" & Me!List2
If Not .NoMatch Then
Forms!CLECS2MainForm.Bookmark = .Bookmark
End If
End With

DoCmd.Close acForm, "GoToREcordDialog"
 
B

Beetle

Sorry about that, I forgot the End If in my example.

Are you getting that error on the .FindFirst Line?

CLEC_ID is a field in the recordset of CLECS2MainForm?
 
C

Confused

Yes, in the .findfirst line. CLEC ID(on the table it is like this with a
space-maybe that's part of the problem? ) is a field in the CLECS2MainForm.
The dialog form is based off the same table.
 
C

Confused

Here's the way it's set up. I got the idea out of an access book (The code
at the top was copied verbatum) I then changed it after I got a reply on the
forum.

I set up an unbound form called "goToRecordDialog" I put a list box on
there that has fields from CLECs2, which is the record source of
CLECS2MainForm. On CLECS2MainForm I see one record at a time. This dialog
form that opens "goToRecordDialog " is supposed to "pop up" and allow me to
scroll through the records, which it does. When I select the command button
on the dialog to go to the record that is selected, that is when I get the
error.

When you rate the post, does that just mean answer yes or no if helpful?
 
D

David W. Fenton

CLEC ID(on the table it is like this with a
space-maybe that's part of the problem? ) is a field in the
CLECS2MainForm. The dialog form is based off the same table.

Try putting brackets around it:

.FindFirst "[CLEC_ID]=" & Me!List2

I can't recall if underscore in a fieldname is one of the characters
that require brackets, but in criteria like this, I always include
the brackets whether there's an obvious need for them or not.
 

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