AutoNumber & ComboBoxes

N

Nick Bradbury

Hi,

I am having difficulty selecting records using a combo box. The scenario is
as follows

1 Samples are received into stock for testing - on receipt the sample is
assigned an autonumber and is stored in a table "LabSamples" with the
following fields

LabNo - Autonumber
OrderID - Number [Long Int] - receiving P.O
ProductID - Text

2 I want to use this table or a query based on this table in a form, using a
combo box to select the LabNo. However when I set up the form Access will
not allow selection of the Lab No listed as they "cannot be edited as they
are linked to an auto-number".

Any suggestions on how I can resolve this would be gratefully received.

N Bradbury
 
R

Rod Scoullar

Nick,

What is happening is that when you open the form the first record is opened.
When you change the combobox you are changing (or trying to change) the
value of the LabNo for that first record. You can't do this hence the
error.

You have to remove the controlsource so the combobox becomes unbound.

When you have done that put this code into the combobox AfterUpdate event
and try it.

Private Sub cboLabNo_AfterUpdate()
Me.RecordSource = "Select * From LabSamples Where LabNo=" & cboLabNo
End Sub

Rod Scoullar
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top