Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo Box, form doesn't update after new records are added 1

Status
Not open for further replies.

vivasuzi

Programmer
Jun 14, 2002
183
Hi!

I have a combo box, as many people seem to. Right now it's pretty straight forward. Selecting a company from the combo will bring up that companies info in the subform.

Here's how -->

Code:
Me.RecordsetClone.FindFirst "[COMPANYname] = " & Chr(34) & Me![Combo28] & Chr(34)
Me.Bookmark = Me.RecordsetClone.Bookmark
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70

Ok that works.

Then I have an Add a Record Button, hitting this will open a blank record for the user to add

Code:
DoCmd.GoToRecord , , acNewRec

Works fine, however I had trouble with people trying to add one record right after the other. So I came up with this idea, I added a Save New Record button. After the user enters in the new company info, they hit Save. This saves and data refreshes and form goes back to first record.

Code:
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
DoCmd.GoToRecord , , acFirst

---------------------------------
PROBLEM:

When the user adds the new record, it is saved just fine, and refreshs to show in the combo box. HOWEVER, if the user chooses to select this record later on, it will not come up. Instead the first record comes up. So even though it's Saved and Refreshed, it won't come up in the subform UNLESS you close the form and reopen it.

This is a pain. Please help! I was thinking there might be a few lines of code I could add into the Combo Box so that if you select from the Combo Box, it automatically refreshes data in the Sub Form so that you have can see the new records.

If more info is needed, let me know!

[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
Have you tried the Requery method ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Ok thanks! Problem A solved.

Problem B.

I also have a delete button. The Delete Company button is in the subform, so my problem is that when I delete a company, all the info is cleared from the sub form except the Company name bc as far as the subform knows, that's the only data.

How do I get it to refresh the main form and go back to the first record? I tried refreshing after delete, but that only refreshes the subform. Any suggestions?

Here's what I got:

Code:
DoCmd.DoMenuItem acFormBar, acEditMenu, 8, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acEditMenu, 6, , acMenuVer70
DoCmd.GoToRecord , , acFirst

but like I said, that only takes you to the entry you just deleted b/c as far as the subform is concerned, that is the only entry. I want to go to the very first entry in the table.

[cat2] *Suzanne* [elephant2]
[wavey] [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top