Do I need a requery?

davesmith202

Employee of Access World
Local time
Today, 05:33
Joined
Jul 20, 2001
Messages
522
I have my Contacts form open. My Company form is also open, with a subform having contact data. I add a record to my subform. But, if I then go to my Contacts form, I see the record is not in my Contacts form unless I reopen that form.

Do I need to do a requery or something?

I ask because I have a combo box that searches for a record in the header of my Contacts form and it won't find the new record unless I reopen the form, which is a pain.
 
Completely aside, as I'm curious about the situation...

Employee of Access World

Join Date: Jul 2001
What have you been doing there for the last thirteen years?
 
@vbaInet, I tried that but if I do a Me.Requery, I get an errory Type Mismatch when I try to run my combobox search. Not sure why. Any ideas?

@Mile-O, I am not a full time programmer.
 
Data Type mismatch? Sounds like a delimiter issue. What's the line you use to reference your combobox?
 
You need to do two things after adding the record:
1. Save it
Code:
If Me.Dirty Then Me.Dirty = False

OR

DoCmd.RunCommand acCmdRecordSave
... I don't remember if it's RecordSave or SaveRecord
2. Requery the other form (not the current form)
Code:
Forms("FormName").Requery
 
As for point 2, it's either you Requery it in the other form or Requery it when you set focus to it (i.e. Activate event or Got Focus).
 
Thanks @vbaInet. How do I trigger the code? My subform is in datasheet and after I enter a record, I click off the row anyway to save. But perhaps that's where the "dirty" thing comes in.
 
How do you save records? Do you have a button for saving records?
 
Client has cut the budget so they don't want me to do this part. Not for now anyway! But for the record, there was no button for saving records. Just click off the subforms datasheet row.
 

Users who are viewing this thread

Back
Top Bottom