Adding a new record to a form

RobMoo

Registered User.
Local time
Today, 05:54
Joined
Feb 10, 2010
Messages
18
I have a form with two combo boxes on it. The combo boxes are synchronised using a query so that when I select a value from combo 1, combo 2 is filtered.

My problem is that once Ive selected a value in both combo boxes and add a new record, both the combo boxes retain the values from the previous record.

Im fairly new to access so any help very much appreciated.

Thanks
Rob:(
 
If I understand what you are doing you make selections in 2 combo boxes and then create a new record? Exactly how is the new record created?
 
Hey Rob, try putting me.Refresh in the AfterInsert event of the form.

This should make recent changes to the database visible in you combo boxes.

Code:
Private Sub Form_AfterInsert()
    Me.Refresh
End Sub
 
Hey Rob, try putting me.Refresh in the AfterInsert event of the form.

This should make recent changes to the database visible in you combo boxes.

Code:
Private Sub Form_AfterInsert()
    Me.Refresh
End Sub
Hi There,
This didn't work either Im afraid?

I have a button that i press to add a new record, but when i press this it adds a new record but both combo boxes retain the values from the previous record?
 
The combo boxes sound like they are UNBOUND then. Unbound controls will do that. If you want to clear them then you would need to clear them in the form's Current event.
 
If I understand what you are doing you make selections in 2 combo boxes and then create a new record? Exactly how is the new record created?

Hi There,

I have a button that i press to add a new record, but when i press this it adds a new record but both combo boxes retain the values from the previous record?
 
Hi There,

I have a button that i press to add a new record, but when i press this it adds a new record but both combo boxes retain the values from the previous record?

I think he was asking what is the code or macro action BEHIND the button that adds a new record. HOW is it adding the new record?
 
I think he was asking what is the code or macro action BEHIND the button that adds a new record. HOW is it adding the new record?

Ive just used the button wizrad
 
So that would create a macro to move to a new record and your combo boxes would then not be bound otherwise they would clear out or go to a default value when moving to a new record.
 
AS a new comer to Access ... how do I bind the combos ?
 
You go click on the control while in design view and go to the CONTROL SOURCE property and select the field from the dropdown list that appears when you click in that property.
 
One of my combo boxes control source has this query

SELECT AircraftFleet.[manufacturer] & " - " & [Name of type] & " - " & [series] & " - " & [registration] AS Manufacturer
FROM AircraftOperatorsQuery INNER JOIN AircraftFleet ON AircraftOperatorsQuery.ID = AircraftFleet.ID
WHERE (((AircraftOperatorsQuery.ID)=[Forms]![Menu1].[cboAircraftOperators]));

what do i put in the control source property of the form ?
 
That shouldn't be the control source. It should be the ROW source and the control source gets the field for whatever ID you are trying to store for that value.
 
That shouldn't be the control source. It should be the ROW source and the control source gets the field for whatever ID you are trying to store for that value.

my rowsource is the query name : FleetComboSync
My control source is blank

>?
 
my rowsource is the query name : FleetComboSync
My control source is blank

>?

And so, if your form is bound to a table or query then you should be able to select one of the fields (in the control source property dropdown) which would match up to the data that the combo is selecting and that would bind that combo to that field.
 
Could be a stupid post but..after you press the button perhaps the form should change all fields containing values and actively null them?

So if nothing else works try
----

Private Sub Form_after update()
If Not IsNull(combo_box.Value) Then
combo_box = Null
combo_box2 = null
End If

End Sub

--

Either genius or pure stupidity, I'm new to access too, but not to db modelling / programming
 
Last edited:
And so, if your form is bound to a table or query then you should be able to select one of the fields (in the control source property dropdown) which would match up to the data that the combo is selecting and that would bind that combo to that field.

This is perhaps where Ive gone wrong... My form is bound to another table called QUOTES and my combo box is attached to to the query

Any ideas
 
You may be better off spending 5minutes recreating the form? if you just have 2 combo boxes and an add record button, you should have it all linked up in no time!
 
You may be better off spending 5minutes recreating the form? if you just have 2 combo boxes and an add record button, you should have it all linked up in no time!

That won't solve my problem..Ive tried that already
 

Users who are viewing this thread

Back
Top Bottom