Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compile error method or data member not found ??

Status
Not open for further replies.

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
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
The error line: ADOCn.ConnectionString = ConnString
[ponder]
 
Do you need to add the relevant object in Project > References?

- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
also
>Public ADOCn As ADODB.Command
[tt]Public ADOCn As ADODB.[red]Connection[/red][/tt]
 
Thank you for your reply friends,Now when i run the program is no more error already,but Why my database still cannot in sequence number ? anything wrong ? where the GetNewBarcode write in ? (eg: command button,click event).

 
For a new problem, start a new thread. Otherwise people might ignore it having seen the beginning of the thread and concluding they had nothing further to contribute.

Also, take a little more time to describe your new problem. It's not clear at all what you want or what you're getting.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top