Re: module
- From: Gman <nah>
- Date: Thu, 02 Feb 2006 13:48:20 -0600
I'm not sure what it could be. Maybe a problem with your declarations. Something that confused me about your other posts is:
Dim adoConnection As ADODB.connection
Set adoConnection = New ADODB.connection
I don't understand why connection is not written Connection - that should be automatic. So it suggests something funny is going on to me.
I would break down the .Open line in an attempt to work out where the trouble is. See below, and find out what line it trips up on.
'--------------
connectString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Documents and Settings\My Documents\System\yDatabase.mdb"
'open the connection with the above string
adoConnection.Open connectString
If adoconnection.State <> adStateOpen Then
msgbox "problem connecting"
exit function 'or sub
end if
adoRecordset.Open ("Select * From Product"), adoConnection, ,
With adoRecordset
set .ActiveConnection = adoconnection
.CursorLocation = adUseClient
.CursorType = adOpenForwardOnly
.LockType = adLockPessimistic
.Open "Select * From Product"
End With
'-----------------------
Also, if you post your full code (including declarations) it would be easier to nail down the problem.
Pinto1uk wrote:
Hi, thank you for pointing me on the right direction. I have managed to solve the problem and the error does not occur anymore. But now i come across another error: Object Required..
This line below is the cause of the error:
adoRecordset.Open ("Select * From Product"), adoConnection, , adLockPessimistic
this is because i am trying to use the recordset object that has been declared and set in the module. cannot find any solutions using google.
regards
regards
"Gman" wrote:
I can probably help you help yourself. You have to report the correct error message to the group. I don't think your error message is "variable or procedure expected not module"
I think it's "Expected Variable or Procedure not Module"
Copy that into google, including quotes. The very first result has someone explaining the likely cause of the error.
It took me about 10" to google it. That's got to be a fraction of the time it takes to write a post (or rather copy and repost your earlier post) and wait for a response.
So as part of the google training exercise I'm not going to tell you the answer - it's on google: clue.... it involves module names. If that's not it... then post back. :-)
Pinto1uk wrote:
Hi, i am using the code below over and over again to connect to my database. I have tried to place in within a module and call it from whereever i need it, but i get the error stating: variable or procedure expected not module. can anyone help.
Dim adoConnection As ADODB.connection
Dim adoRecordset As ADODB.Recordset
Set adoConnection = New ADODB.connection
Set adoRecordset = New ADODB.Recordset
'build our connection string to use when we open the connection
connectString = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=C:\Documents and Settings\My Documents\System\yDatabase.mdb"
'open the connection with the above string
adoConnection.Open connectString
- Follow-Ups:
- Re: module
- From: Gman
- Re: module
- References:
- Re: module
- From: Gman
- Re: module
- Prev by Date: Re: Stumped -- trying to update a VBA subroutine for VB.net
- Next by Date: Re: Do we have such a container control?
- Previous by thread: Re: module
- Next by thread: Re: module
- Index(es):
Relevant Pages
|