D
David_Williams_PG ()
I am trying to copy some values from the table Product_data_new using a combo
box [Code as below] to pick out the ID value from the table and then the code
should pick out the other values from the same line and copy these into a
form - but the code is not recognising the .FindFirst .NoMatch statements
within my " With Rst clause ".
Am using Access 2002 with references :-
Visual Basic for Applications
Microsoft Access 10.0 Object Libary
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 Object Libary
Visual Basic for ApplicationsExtensibility 5.3
Any help much appreciated,
dw
----------------------------------------------------------------
Option Compare Database
Option Explicit
-------------------------------------------------------------------
Public Function getfieldname(commentnum As Double)
Dim db As Database
Dim rst As Recordset
Dim commstr As String
Dim strCriteria As String
' Define search criteria.
strCriteria = "[ID] = " & commentnum
Set db = CurrentDb()
Set rst = db.OpenRecordset("Product_data_new", dbOpenDynaset)
With rst
If .RecordCount > 0 Then
.FindFirst strCriteria
If .NoMatch Then
getfieldname = "not found"
Else
getfieldname = ![MAT_CODE]
Me![MAT_CODE] = ![MAT_CODE]
Me![EAN] = ![EAN]
Me![PACK_LEV] = ![PACK_LEV]
Me![SHORT_DESC] = ![SHORT_DESC]
Me![BUS_CAT] = ![BUS_CAT]
End If
End If
.Close
End With
End Functio
box [Code as below] to pick out the ID value from the table and then the code
should pick out the other values from the same line and copy these into a
form - but the code is not recognising the .FindFirst .NoMatch statements
within my " With Rst clause ".
Am using Access 2002 with references :-
Visual Basic for Applications
Microsoft Access 10.0 Object Libary
OLE Automation
Microsoft ActiveX Data Objects 2.1 Library
Microsoft DAO 3.6 Object Libary
Visual Basic for ApplicationsExtensibility 5.3
Any help much appreciated,
dw
----------------------------------------------------------------
Option Compare Database
Option Explicit
-------------------------------------------------------------------
Public Function getfieldname(commentnum As Double)
Dim db As Database
Dim rst As Recordset
Dim commstr As String
Dim strCriteria As String
' Define search criteria.
strCriteria = "[ID] = " & commentnum
Set db = CurrentDb()
Set rst = db.OpenRecordset("Product_data_new", dbOpenDynaset)
With rst
If .RecordCount > 0 Then
.FindFirst strCriteria
If .NoMatch Then
getfieldname = "not found"
Else
getfieldname = ![MAT_CODE]
Me![MAT_CODE] = ![MAT_CODE]
Me![EAN] = ![EAN]
Me![PACK_LEV] = ![PACK_LEV]
Me![SHORT_DESC] = ![SHORT_DESC]
Me![BUS_CAT] = ![BUS_CAT]
End If
End If
.Close
End With
End Functio