hwkong1688
Technical User
- Jun 5, 2010
- 6
When I run got this error msg: compile error method or data member not found
My code is
The error line: ADOCn.ConnectionString = ConnString
My code is
Code:
'in a module
Public ADOCn As ADODB.Command
Public ConnString As String
Public adoRS As ADODB.Recordset
Public strBarCodeNo As String
Public Sub OpenDB()
ConnString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\path\to\your\database\toys.mdb;" & _
"Persist Security Info=False"
Set ADOCn = New ADODB.Connection
ADOCn.ConnectionString = ConnString
ADOCn.Open ConnString
End Sub
'on your startup form
Private Sub Form_Load()
OpenDB
End Sub
'now your database is open - get the next barcode number
Private Sub GetNewBarcode()
Dim sSQL As String
'get next available appeal number
Set adoRS = New ADODB.Recordset
sSQL = "SELECT MAX(barcode) FROM barcode "
adoRS.Open sSQL, ADOCn
If IsNull(adoRS(0)) Then 'then this is the first of the new records
strBarCodeNo = "95551170000"
Else 'just increment from what is there
strBarCodeNo = Format$(Val(Mid$(adoRS(0), 1) + 1), "0000")
End If
End Sub