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
Terry - 31 Mar 2005 15:01 GMT
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
> 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.
[quoted text clipped - 10 lines]
> varX = DLookup("[prodvols05]", "Main details", [ModelName])
> End Sub
Tim Ferguson - 31 Mar 2005 17:54 GMT
> 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