Back to the .... Form

michi.for

Registered User.
Local time
Today, 13:51
Joined
Jan 13, 2016
Messages
45
Hi all and ty for your precious support.

I have an issue:

I have a data entry form where i put all things about a client purchase (like Name, Cost, and so on...).

There is a COMBOBOX used to find the client name.
The combobox use a query (based on Client table) that merge NAME and SURNAME.
If the name isn't founded i can push a button that brings me to another form where i can put the name and surname.
When putted, with the button SAVE AND CLOSE (with this vba command):

' Return Control object pointing to a combo box.
Set ctlCombo = Forms!FirstForm!ComboboxName
' Requery source of data for list box.
ctlCombo.Requery
DoCmd.Close

I close the form and come back to the first one.

The issue is that when i re-use the Combobox, don't refresh with the new name and i can't find it.

Is there a problem with the vba code?
There is another way to have the same result?

TY
 
you may have refreshed the variable ctlCombo instead of the actual control,
instead of that, use this:

' Requery source of data for list box.
Forms!FirstForm!ComboboxName.requery
DoCmd.Close
 
you may have refreshed the variable ctlCombo instead of the actual control,
instead of that, use this:

' Requery source of data for list box.
Forms!FirstForm!ComboboxName.requery
DoCmd.Close


I think is the same...or not?
 
it may not be.
you refreshed the variable then erased it when you left the sub.
the ACTUAL control did nothing, so just refresh the actual.
 
it may not be.
you refreshed the variable then erased it when you left the sub.
the ACTUAL control did nothing, so just refresh the actual.

Tried, but nothing.
The combobox not showing the new "name".

Only after closing and re-opening the first form, the combobox show the name.
 
Ok i solved putting the code:
Forms!FirstForm!ComboboxName.requery
Inside the Form event Close().

...why? What is the difference putting the code on ONCLICK() (and docmd.close) and in CLOSE() ?????

Seems the same action clicking on a button....isn't it?
 
on your save and close button did you actually save the record using DoCmd.RunCommand acCmdSaveRecord or me.dirty=false.
 
if you have saved it then how come requery will not work on your button.
closing the form with pending add/edited record will forced it to save.
 

Users who are viewing this thread

Back
Top Bottom