473,396 Members | 1,961 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Clear the value of a filter combo box when adding a new record

Hello,
I have a form and a combo box that I use to filter the form to particular records. I also have an "add new" button that, when clicked, adds a new record. My problem is that the filter combo box stays on the old selection when the new record pops up. I would like to have the combo box clear or set to a default value of "New" when the Add New button is clicked or when the user clicks on the * (new record) button in the navigation bar.

The On Click event code for my add new button is currently:
Expand|Select|Wrap|Line Numbers
  1. Private Sub btnAddSiteVisit_Click()
  2. On Error GoTo Err_btnAddSiteVisit_Click
  3.  
  4.     DoCmd.GoToRecord , , acNewRec
  5.  
  6. Exit_btnAddSiteVisit_Click:
  7.     Exit Sub
  8.  
  9. Err_btnAddSiteVisit_Click:
  10.     MsgBox Err.Description
  11.     Resume Exit_btnAddSiteVisit_Click
  12.  
  13. End Sub
  14.  
I had tried to add a requery command and give the combo box a default value, but this did not work. Any advice / help is GREATLY appreciated!

Bridget
Oct 23 '07 #1
6 4996
Rabbit
12,516 Expert Mod 8TB
Add:
Expand|Select|Wrap|Line Numbers
  1. Me.cbo_ComboBoxName = "New"
  2.  
After the DoCmd.
Oct 23 '07 #2
FishVal
2,653 Expert 2GB
Or something like the following in Form_Current event handler.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Current()
  2.     With Me
  3.         If .NewRecord Then .cboYourCombo = .cboYourCombo.DefaultValue
  4.     End With
  5. End Sub
  6.  
This will run whenever form gets to new record - programmatically, via form navigation buttons or via menu commands.

Regards,
Fish.
Oct 23 '07 #3
NeoPa
32,556 Expert Mod 16PB
That's a nice idea Fish.
Quite "general purpose" :)
Oct 24 '07 #4
That's a nice idea Fish.
Quite "general purpose" :)

Sorry for the delayed response, I got pulled into another project temporarily. Thank you for these suggestions! I will try them and repost if I have questions.
Best,
Bridget
Oct 25 '07 #5
Sorry for the delayed response, I got pulled into another project temporarily. Thank you for these suggestions! I will try them and repost if I have questions.
Best,
Bridget

Fish's suggested code works perfectly!
Thank you!!!!!!!
Bridget
Oct 25 '07 #6
NeoPa
32,556 Expert Mod 16PB
Good for you Bridget, and good luck with your project :)
Oct 26 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: William Wisnieski | last post by:
Hello Again, I'm really stuck on this one.....so I'm going to try a different approach to this problem. I have a query by form that returns a record set in a datasheet. The user double...
8
by: Zlatko Matić | last post by:
There is a form (single form) and a combobox. I want that current record of the form is adjusted according to selected value in the combobox. Cuurrent record should be the same as the value in the...
3
by: ILCSP | last post by:
Heello, I'm using Access 2000. I have a form with a combo box that has a query as its row source and it's bound to column 1. This combo box is unbound to a record like the rest of the form...
9
by: Ecohouse | last post by:
I have a main form with two subforms. The first subform has the child link to the main form identity key. subform1 - Master Field: SK Child Field: TrainingMasterSK The second subform has a...
2
by: AA Arens | last post by:
I have a form with a combo account manager (choose the name) I have record navigation buttons on that form, along with other fields. I do not use queries, only tables. One of the tables is the...
6
by: bammo | last post by:
MS Access 2003, Windows XP SP2, VBA I have a continuous form that allows edits and filters, but not deletions or additions. I filter the form based on combining selections the user makes in...
3
by: birt | last post by:
I know I am getting in my own way .... so someone please save me from myself! I created a form and rather than force the users to scroll through all the records to find theirs I decided to have...
2
by: banderson | last post by:
Hello, I have a data entry form for a table with information about buildings and am having a problem making a combo box do what I want. I would like to make the combo box show a list of unique bldg...
5
by: banderson | last post by:
Hello I have an "add new" button on a form. I would like the button to go to a new record AND filter the form on that new record. The form also has an unbound combo box used to look for and filter to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.