Try breaking it down into steps, to see where the problem lies.
This kind of thing:
Dim strWhere As String
Dim varResult As Variant
If Not IsNull(Me.ModelID) Then
strWhere = "ModelID = "& Me.ModelID
varResult = DLookup("ModelRetailCost", "Table 1", strWhere)
If Not IsNull(varResult) Then
Me.ModelRetailCost = varResult
End If
End If
--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"Alberto" <Alberto@[EMAIL PROTECTED]
> wrote in message
news:A16CDDA2-9736-4F1F-92D9-ABE38BC72643@[EMAIL PROTECTED]
> Thanks. I think I'm almost there.
>
> I typed the following into my form:
> Forms![frmQuotes]!ModelRetailCost = DLookup("ModelRetailCost", "Table
1",
> "ModelID = " & Forms![frmQuotes]!ModelID)
>
> When I ran this I got the following error: Data Type Mismatch in
Criteria
> Expression.
>
>
>
>
> "Allen Browne" wrote:
>
>> Use the AfterUpdate event procedure of Textbox1 to DLookup() the price
of
>> the ModelID in Table2.
>>
>> For an example, see the Northwind sample database. In the Order Details
>> subform, the ProductID combo has this kind of AfterUpdate event
procedure
>> to
>> get the price each from the Products table.
>>
>> If you need help with DLookup(), see:
>> Getting a value from a table: DLookup()
>> at:
>> http://allenbrowne.com/casu-07.html
>>
> "Alberto" <Alberto@[EMAIL PROTECTED]
> wrote in message
>> news:7861EB88-C542-4378-9531-797D9F53AE00@[EMAIL PROTECTED]
>> > Here's what I need to do:
>> > Prompt the user to enter a ModelID in TextBox1 and have the
>> > ModelRetailPrice
>> > for that ModelID returned in TextBox2 - both the ModelID and
>> > ModelRetailPrice
>> > are in Table1. Once the user does this they can enter data in
TextBox3
>> > and
>> > TextBox4. I then want TextBox1, TextBox2, TextBox3 and TextBox4 to
be
>> > stored
>> > in Table 2. How do I do this?


|