Clear a form using macro?

rudeboymcc

Registered User.
Local time
Today, 00:38
Joined
Sep 9, 2008
Messages
69
Hi there. I need to clear all the data from a form before requerying it. is this possible? at the moment i've found if i press Esc to remove all the data i've got so far, it's fine. is tehre anyway to "press esc" with a macro?
 
if pressing esc does what you want, then you can use

vba command

sendkeys "{esc}"


although this actually UNDOES the previous edit
 
that's what i need it to do because hte users keep changing one value and then leave the form with another value empty but required, and so they get loads of errors.

thanks for this solution but is there maybe a macro way? rather than using a runcode command...
 
actually this doesn't work as well as i thought it would.

say a user is typing in the combo box to search if the name exists. once he realises that there's no name like that, he clicks on the "new contact" button, but because there's text in the combo box, i get the message "the text you entered isn't an item in the list".

This seems to happen on the "lost focus" event of the combo box .is there any way to make this error go away and just clear the box instead?
 
in a combo box, there is a notinlist event, which occurs if you type something not in the list.

so rather than have a different button, the normal technique is to use this event to open the form (or insert it with sql) to add a new record, and then on return to requery the combo box record set, as the new record will now be present.

there is also a "limit to list" status for the cbobox, and offhand i am not certain whether this has to be true or false with this technique
 

Users who are viewing this thread

Back
Top Bottom