Selecting a record and getting data from a field.

  • Thread starter Thread starter Pringle9984
  • Start date Start date
P

Pringle9984

In my code I use the following line (primarily as part of an i
statement)

numRowsFrom = DCount("*"
"[sc_object]", "[location_id] =
& LocationFrom & " AND [material_id] =
& Material

Is there any way I can select the first record returned directly fro
the DCount or will I need to do a seperate DLookup

In either case - once the appropriate record is found I'd like t
retrieve the value of 'object_qty' for use within another part of m
code; something like

[code:1:6a5c172fd3]prevQty = sc_object.object_qt
newQty = prevQty + qty[/code:1:6a5c172fd3

Any help would be greatly appreciated
 
You'll need to use another dlookup to get the quantity or use open recordset
to do both actions

Dim MYDB As Database, MyRec As Recordset
Set MYDB = CodeDb
Set MyRec = MYDB.OpenRecordset("SELECT * FROM [sc_object] WHERE
[location_id] = " & LocationFrom & " AND [material_id] = " & Material)
If Not MyRec.EOF Then
MyRec.MoveLast
numRowsFrom = MyRec.RecordCount
MyRec.MoveLast ' will take you back to the first record
prevQty = MyRec!object_qty
newQty = prevQty + qty
End If
 
Back
Top