Auto fill a form

  • Thread starter Thread starter Val Whitehead
  • Start date Start date
V

Val Whitehead

Guest
I need to auto fill the fields in a form.. I want to select a name from a combobox drop down list based on a table or query, and have Access auto fill in other related fields (address, phone, etc.) from the same table or query..

Thank you
Val
 
You need an unbound combo box that has a SELECT statement as it's RecordSource that fills in all the record id's and names. Set the ColumnWidth property so that the first column = 0" (invisible). Set the Bound Column to be the column that holds the Record Id's. On the AfterUpdate of the combo box, put in the following

Me.Recordsetclone.FindFirst "record_id = Forms!frmFormName!cboComboBoxName
Me.Bookmark = Me.Recordsetclone.Bookmark

That is all there is to it.....

Chris
 
PHOOEY!!

All I get is a compile error... <smile>
Did I mention that the last time I did any coding, it was 6502 assembly?... PLease be patient I appreciate your help, but apparently I need REALLY BASIC help

Val
 
AHA!

I played with the code a little.. I generated a NEW ERROR.. (new for me anyway) I received a "can't bind record_id" error.

Val
 
Put in VB code


Private Sub Inv__AfterUpdate()

'NOTICE below field [Inv#] must be shown as [Inv_]
'because the # sign cannot be used in VB code.

Me.Description = Me.Inv_.Column(1)
Me.Brand = Me.Inv_.Column(2)
Me.Model = Me.Inv_.Column(3)

End Sub


ANOTHER SUBJECT:

In lookup, if you have choosen 5 columns and you are searching with a RecNum or a IDNumber which is the first column, but you want to choose based on the second column, and you DO NOT want the number to show:

Goto properties, Format, then Column Widths. It looks like this:

1”;1”;1”;1”;1”;

change it to

0”;1;”;1”;1”1”; This will allow you to pick and choose from the second column.
 
This worked out great, but when column(3) is blank I get some sort of error. What code can I add that will skip that field if it is blank. Thank in advance.
 
I am struggling with 'Musicmaker's' code - is this the only code to enter in VB or is there something else ??
thanks in advance
Jerry
 
The VB Code I posted only works with ACCESS 2000. Any older versions will not work.

Below will work in Access97.
DLOOKUP FUNCTION

INV is a table name: field1 = RecNum, field2 = InvNum, field3 = Description
SALES is a table name: field1 = RecNum, field2 = InvNum, field3 = Description

Make a form: form name is = SALES

Put code in: Event Procedure (on Exit)

Me.Description = DLookup("[Description]", "INV", "[InvNum]=forms!Sales.[InvNum]")
End Sub

Me.Description means put the lookup info into the field named Description and Me. Means on this form. (In this case is SALES)
Dlookup is the function name.
Description is the name of the field in the INV table that you want to get the information from.
INV is the name of the table to get the information from.
The first [InvNum] represents the name of the field in the INV table. This is how lookup knows which record to get the data from.
=forms!Sales.[InvNum]”) Points to the field in the form (Sales, in this case) to determine the information necessary to lookup the information in the other table.

-or- another example

=Dlookup(“[the name of the field that you want to get the information from]” , ”the name of the table that the field is in”,”[field name in lookup table that identifies your match] =forms!name of form your in.[field name in the form your in that you want to match]”)

…………………….your in^ ABOVE there must be a period before [field name
 

Users who are viewing this thread

Back
Top Bottom