Follow up to Not in List

  • Thread starter Thread starter Beth
  • Start date Start date
B

Beth

I used the code example and I have it working. However, after the record is
added, I would like to open the form (frmStudents) and go to the record that
matches the record added through NewData so that I can add information about
the individual. I can get the form to open, but I can't make it open to
that record.

Any suggestions?
Thanks,
Beth
 
You can open the form with a filter on it.
Something like this:
DoCmd.OpenForm "frmStudents", , , "RecordID = " & Me.Text0

RecordID would be the name of the tables unique ID field.

Good Luck!
 
I just noticed your other post.
Just change me.text0 to the data you get from the recordset.

DoCmd.OpenForm "frmStudents", , , "RecordID = " & rs!RecordID
 
That is what I was trying, but I must still have something wrong. I have
tried both of the following lines of code. Both open the form, without
error, but they take me to a blank record. Can you explain what I have
wrong?
DoCmd.OpenForm "Students", , , "Forms!Students![ID]=" & NewData
'Where NewData is the number typed and accepted
DoCmd.OpenForm "Students", , , "Forms!Students![ID]=" & rs![StudentID]


Thanks,
Beth
 
I think your problem is " Forms!Students![ID]= ". The Where part of the
docmd is looking to filter the recordsource of the form not a control on the
form. So "Forms!Students![ID]=" should be the table's ID field not the
form's control that shows the ID field.

So i if the field in the table is called "ID" and the form name is
"Students", then it should look like this:

DoCmd.OpenForm "Students", , , "ID =" & rs![StudentID]

Here is an example i did for someone else:
They were filtering the form for three fields looking for a perfect match.
If it didn't find a match it would still filter the form and just leave it
open for adding new records.

DoCmd.OpenForm "frmViewExperts", , , "FirstName = '" & Me.Text0 & "' AND " & _
"LastName = '" & Me.Text3 & "' AND " & _
"OrganisationName = '" & Me.Text5 & "' "

Hope this helps.


Beth said:
That is what I was trying, but I must still have something wrong. I have
tried both of the following lines of code. Both open the form, without
error, but they take me to a blank record. Can you explain what I have
wrong?
DoCmd.OpenForm "Students", , , "Forms!Students![ID]=" & NewData
'Where NewData is the number typed and accepted
DoCmd.OpenForm "Students", , , "Forms!Students![ID]=" & rs![StudentID]


Thanks,
Beth

visdev1 said:
I just noticed your other post.
Just change me.text0 to the data you get from the recordset.

DoCmd.OpenForm "frmStudents", , , "RecordID = " & rs!RecordID
 
Back
Top