FORMS - RETRIEVE RECORD FROM TABLE

C

Chrissy

Hi, I asked for help and then closed the thread because I thought I knew what
I was doing. But I don't. I have a main form with a subform. I am only
working on the main form at this point. The main form is based on a table
CompanyDetails and the form contains all fields from the table. The first
field (Company) on the form is a combo box - set up with the wizard - I chose
"I want the combo box to look up the values in a table" and "Remember the
value for later use" - don't know if these are right. When the user selects
an item from the combo box it displays the CompanyName in the 2nd field on
the form (this is the data source for the combo box). What I want it to
actually do is retrieve the record from the table and put the details in the
form so the user can edit the details if needed - then move onto the subform.

The other problem is that when the user doesn't select from the combo box
and enters a new record the combo box is not updated unless I exit the form
and go back into it. Please help.
 
D

Damian S

Hi Chrissy,

Have the combo box with an OnClick or AfterUpdate Event so that it locates
the selected CompanyID and jumps to that record, like this:

me.recordsetclone.findfirst("CompanyID = " & me.cboCompanyID)
me.recordset.bookmark = me.recordsetclone.bookmark

To get the combo box to update after adding a new company, add the following
into an AfterInsert event for the form:

me.cboCompanyName.requery

Hope this helps.

Damian.
 
C

Chrissy

Thanks Damian.
I got the record retrieved by changing the selection in the combo wizard to
"Find a record" and setting the Data Entry property of the form to NO.
I have tried to put in your code for updating the combo box but have
obviously done it wrong. Should I go to the form properties and then Event?
Then do I select AfterInsert and select EventProcedure? I have done this so
far but then I am lost as to how to enter the code - I have no programming
skills.

The Expression Buider window opens with the name of the Event Procedure -
[RequeryCombo] but I don't know how to enter you line of code. Could you
please give me the syntax for entering it in the expression builder?
Many thanks
 

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