look up table

G

Guest

I have a table that lists letters A - M

Code Min Max
A 1 10,000
B 10,001 100,000
C 100,001 500,000+
other

I have a table that needs one of the letters. It also has 2 fields for min
& max depending on the letter chosen. I need to have the min/max fields
because if OTHER is chosen from the code box, the user needs to be able to
enter the min/max values for OTHER.

The form (data source being the table above) has a combo box to choose the
letter. The min & max text box control sources are Min & Max from the table.
The default value is Dlookup ("[Min]", "tblEstimate", "
Code:
 =" & [Code]).
The default values never show up.  I can only enter data in them.

What am I doing wrong?
 
W

Wayne Morgan

Bind the two textboxes to the form's table. Make the combo box a 3 column
box. If desired, hide the min and max columns. If you choose not to hide
them, the first visible column is what will show in the textbox portion of
the combobox after a selection has been made. In the AfterUpdate event of
the combobox, set the values of the two textboxes. I would also recommend
locking the textboxes unless Other is chosen.

Example:
If Me.cboMyCombo = "Other" Then
Me.txtMin = ""
Me.txtMax = ""
Me.txtMin.Locked = False
Me.txtMax.Locked = False
Else
Me.txtMin = Me.cboMyCombo.Column(1)
Me.txtMax = Me.cboMyCombo.Column(2)
Me.txtMin.Locked = True
Me.txtMax.Locked = True
End If

The Column index is zero based, so 0 is the first column, 1 the second
column, 2 the third column, etc.

Since the textboxes are bound, the values in them will be written to the
table when the record is saved.
 

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