Problems

  • Thread starter Thread starter MAG
  • Start date Start date
M

MAG

I set up a command button to open a specific record by
asking for the part number then going to it. I did this by
using the form:
DoCmd.OpenForm "form", , , "[Field] = '" & Part & "'"

But now when I try to use the previous and next record
commands it doesnt do anything because all that is open is
that one field. Is there anyway I can open all the
records for this form and still have it go to the one I
want. So after I goto the part I want I can scroll through
all the records without reopoening the form.
Thanks for any help.

MAG
 
Hi Steve
Thanks. So far I think that has solved my problems.
Thanks Again
MAG
-----Original Message-----
Hi MAG,

You could use the recordsetclone and bookmark to go to the desired record
while still loading all records. In your cmdbutton use something like this
(using DAO).

DoCmd.OpenForm "formName"
Forms!formName.RecordsetClone.FindFirst "[FieldName] = '" & Me.Part & "'"
If Not Forms!formName.RecordsetClone.NoMatch Then
Forms!formName.Bookmark = Forms! formName.RecordsetClone.Bookmark
End If

I am assuming "Part" is on the form with the cmdbutton that opens the
results form. Just replace formName & FieldName with the correct names.

HTH
Steve C

MAG said:
I set up a command button to open a specific record by
asking for the part number then going to it. I did this by
using the form:
DoCmd.OpenForm "form", , , "[Field] = '" & Part & "'"

But now when I try to use the previous and next record
commands it doesnt do anything because all that is open is
that one field. Is there anyway I can open all the
records for this form and still have it go to the one I
want. So after I goto the part I want I can scroll through
all the records without reopoening the form.
Thanks for any help.

MAG


.
 
Most people who post here have problems. Most of the volunteers who
answer messages expect to find a problem... but it helps a lot if you
describe the problem briefly in the Subject line!
I set up a command button to open a specific record by
asking for the part number then going to it. I did this by
using the form:
DoCmd.OpenForm "form", , , "[Field] = '" & Part & "'"

But now when I try to use the previous and next record
commands it doesnt do anything because all that is open is
that one field.

Yep. That's what the WhereCondition argument is designed to do.
Is there anyway I can open all the
records for this form and still have it go to the one I
want. So after I goto the part I want I can scroll through
all the records without reopoening the form.
Thanks for any help.

You can, but it takes a bit more code. Pass the value you want to find
in the OpenArgs (the last) argument of the OpenForm, and then put code
in the Form's Open event to navigate to that record. For instance,

Dim part As String
....
part = <some value from your form perhaps>
DoCmd.OpenForm OpenArgs:=part

Then in the Form's Open event:

Private Sub Form_Open(Cancel as Integer)
Dim rs As DAO.Recordset
If Me.OpenArgs & "" <> "" Then ' was an argument passed?
Set rs = Me.RecordsetClone
rs.FindFirst "[field] = '" & Me.OpenArgs & "'"
If rs.NoMatch Then
rs.MoveFirst
MsgBox "Part " & Me.OpenArgs & " not found!", vbOKOnly
End If
Me.Bookmark = rs.Bookmark
End If
End Sub
 
Back
Top