Apply DoCmd.SearchForRecord on Seperate Form

padlocked17

Registered User.
Local time
Today, 08:00
Joined
Aug 29, 2007
Messages
276
I have a form that's recourdsource lists all available classes and has a button that opens a "pop-up" modal form.

When a new class is added in the modal pop-up form, they click a "Save Button".

I want that button to essentially run the following command on the original form but I'm not sure how to get the pop-up modal form to search the form from which it originated.

Code:
Forms!frmEnroll.DoCmd.SearchForRecord , "", acFirst, "[ClassID] = " & "'" & PotentialClassName & "'"

'PotentialClassName' is the PK for the new record that was just created in the pop-up modal form.
 
Don't use the DoCmd. Do a DCount or a DLookup on the record source (table or query) of the main form. If either DCount or DLookup returns a zero, then the class doesn't exist.

If DCount("ClassID","YourTableOrQueryName","ClassID='" & PotentialClassName & "'") = 0 Then

ClassName doesn't exist

Else It does exist

Honestly, it sounds like ClassID may be a number of some sort, whereas ClasName is a description, so you may be comparing the wrong fields. I don't know that without seeing the structure.
 
I'm actually looking to move to and find the record that I just created on the modal form instead of looking for if that record exists. I want to move to the record on the main form.

Any ideas on that?
 
I would just typically use the DoCmd.OpenReport and set the Where portion to find what I want ... but the form will be remaining open.
 
How do you have the modal form linked to the main form? IF it's on the PK for the Master/Child relationship, it's straightforward. If the form's aren't connected, we have different issues.
 
Don't you just love it when people answer your post, but don't answer your question? I would have liked to have known the answer to this one myself, as I'm trying to accomplish basically the same thing. I'll have to try posting the question. Hope you'd managed to find a way.
 

Users who are viewing this thread

Back
Top Bottom