Dlookup problem

G

Guest

In a form, I enter a number into a field, what I have is many records, and
lots of duplicate information. It is a database of vehicle information.
When filtered down to a particular Model I may get between 1 and 100 records,
what I need to do is use that entered number in the field on the form and
have it copied automatically, after clicking a button on the form, into all
the relevant field cells according to what model it is. Currently I'm using
CTRL+ Apstrophe ( ' ), which copies the entry which is in the previous cell,
this is very time consuming. Below is the code that I've tried, but it
dosen't work, has anyone got the right coding that I can try.

Private Sub ProdVols05_AfterUpdate()
Dim varX As Variant
varX = DLookup("[prodvols05]", "Main details", [ModelName])
End Sub
 
G

Guest

I think the syntax for DLookup is
DLookup(<Fieldname>,<Tablename>,<Where Clause>)
meaning that [Modelname] should be "[Modelname] = " &[ModelName]

varX = DLookup("[prodvols05]", "Main details", "[ModelName] = " &[ModelName])
Terry
 
T

Tim Ferguson

what I need to do is use that entered number in the field on the form
and have it copied automatically, after clicking a button on the form,
into all the relevant field cells according to what model it is.

strSQL = "UPDATE MyTable " & _
"SET SomeNumber = " & Me!NumberControl.Value & " " & _
"WHERE Model = " & Quoted(Me!ModelDescription)

Currentdb().Execute strSQL, dbFailOnError


I don't think that DLookup comes into it..?

HTH

Tim F
 

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

Similar Threads

DLookup error 1
Error Msg 3
DLookup referencing a subform 2
Custom Function to return array 2
help with Dlookup 2
DLOOKUP coding issue 13
DLookup Challenge 11
DLookup code for auto-populating a control on a form 1

Top