PDA

View Full Version : If search not found through Combo Box....



wasim_sono
05-29-2008, 12:47 AM
I am using combo box on my form through which the specific record was found. the problem is that if required record not found then combo box shows a particular record. I need that if record not found then combo box should be empty and related sub form should also be empty or showing null record.

Thanks.

Wasim

OBP
05-31-2008, 04:01 AM
What "Find" code are you you using in the Combo's After Update Event?

wasim_sono
06-01-2008, 09:00 PM
Hello OBP

Glade to see u. I just using the wizard of combo box in which I used the third option of wizard. as a reply on another forum I used the property 'Limit to list' but still it display the particular record. I want to empty all fields of forms as well as sub form's fields. the screen shot of situation is attached.


Thanks.

Wasim

OBP
06-02-2008, 08:45 AM
Wasim, I don't really understand, I thought the whole point of using the Combo in that was that it lists all the available records for you.
Therefore if it is not in the list you can just go to a new record.
Have you looked at the "Not in List" property?

wasim_sono
06-02-2008, 08:17 PM
Dear OBP

I used the 'Not in list' property. I used a msgbox displaying the message about not existing record as shown in screen shot. but the form and sub form still showing filled fields. I want that fields should be empty if not found in the list of combo box.

Thanks.

Wasim

OBP
06-03-2008, 03:25 AM
Wasim, can't you replace the Msgbox with
me.newrecord
to go to a new record, you could even populate the new record with whatever the user has entered in the combo. To do so set a variable to the combo and then in the new record set the relevant field to the variable.

wasim_sono
06-06-2008, 11:32 PM
Yes of course OBP

I'll do it if help me to write the VBA code for this.

Thanks.

Wasim

OBP
06-07-2008, 02:30 AM
wasim, where you have the message box code
msgbox "blah blah"
replace it with
DoCmd.GoToRecord acDataForm, "FormName", acNewRec
where FormName is the name of your form.

wasim_sono
06-10-2008, 05:53 AM
Dear OBP

As I used your reffered code in my application it returns a run time you can't go to the specified record. The code is as follow.

docmd.goto record acdataform, "enquirybyid" , acnewrec

Secondly I want to create three combo box as that second depends on 1st combo box and 3rd depends on 2nd combo box. These combo boxes are unbounded and control sources are three different queries.

Thanks.

Wasim

OBP
06-10-2008, 06:07 AM
Wasim, if you can't go to a new record then either you have "Allow additions" set to "No" on the Form's properties or the Recordset is not "Updatable".
Can you post a zipped copy of the database?
The combo's Query's criteria row should have the previous Combo as it's criteria.