Entering new record using Combobox

trebor3900

Registered User.
Local time
Today, 15:23
Joined
Apr 26, 2005
Messages
47
I have a form [tblStock]with a combobox bound to the Primary key [ContactID] of a table [tblContacts].
Also on the form is a subform[subContacts] bound to a query that is based on the value of the combobox
on the form. So that the details of the combobox[ContactID] is shown in the subform [subContacts].

The trouble is that i dont seem to be able to add a new ContactID in the combobox and fill in the rest
of the details in the subform.

Problem 1 is that the focus moves to a textbox that i have on the form[tblStock] when
i enter the first character into the combobox.

Problem 2 is that when i continue to click into the combobox and type the ContactID that
i have typed does not get ammended to the table[tblContacts].

I am very new to Access, it probably shows, but this problem is driving me mad....Anyone?
 
Can you post a zipped copy of your database? My feeling is that your query might be restricting the records to the point that all the fields need to allow a new record to be created are not selected on your query. If you open your requery alone, do you get the option to add a new record, if you don't redefine your query.
 
DB too large

Can't post as it is cos it is too large. I have to go to work now but will try and trim the zip file down to the essential components and post. Thanks for the time.
 
If the focus is moving I would check for code behind the Combobox as well

Peter
 
DB zip

The form in question is [frmStationStock] and the combobox is [cboRecipientStation].

Thanks again for your time
 

Attachments

In looking at your database I see that you are firing a lot of events oncurrent and on change and you are moving the focus all over the place. When I opened the form I was hit by a bunch of Update record warning, turn off the warnings by entering docmd.Setwarnings False at the top of the onOpen event for the form. You will definately benifit a lot more by moving your events to the After Update event, this will let you complete writing what you want on the field before the event is triggered. By having the OnChange event it fires it everytime you enter a new letter, therefore it moves you off the control without letting you complete what you are trying to write. In looking at your code I see a lot of things that can be done differently, you need to change the Macros to VB Code so that you can see what is happening. I tried chaging the Combobox to a different value and next thing you know a macro was crashing on me. The macro was being called by the onchange event of the 2nd drop down list since your code changes it to Not Selected. There are a lot of other sections that need to be improved, but start with these.
 

Users who are viewing this thread

Back
Top Bottom