Now when I click on ModelID in the Form, nothing happens. It's as if there
were no code. I don't get an error but I can go on to the rest of the
form
and make other changes.
"Allen Browne" wrote:
> So if yuo open your table in desigtn view, what Type is ModelID?
>
> If it is Text (not Number), you need extra quotes:
> strWhere = "ModelID = """ & Me.ModelID & """"
>
> Explanation:
> Quotation marks within quotes
> at:
> http://allenbrowne.com/casu-17.html
>
> --
> 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:84131FA3-655B-43A5-90DB-4C01011A3BF4@[EMAIL PROTECTED]
> >I still received the same error. This time in this line:
> > varResult = DLookup("ModelRetailCost", "Table 1", strWhere)
> >
> > I also tried doing it this way:
> >
> > Private Sub ModelRetailPrice_AfterUpdate()
> > DLookup("ModelretailPrice","tblModel", "ModelID = '" &
> > Forms![frmQuotes]!ModelID & "'")
> > End Sub
> >
> > but when I did, nothing happened.
> >
> >
> >
> >
> > "Allen Browne" wrote:
> >
> >> 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
> >>
> >> "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?
> >>
> >>
>
>


|