|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Help with ADO...
My first real attempt at using an ADO connection. Have always used bound forms in the past.
Please review my code and offer help! Getting an error...Object variable or With block variable not set. Private Sub btnPreviewChecks_Click() Dim rstTemp As ADODB.Recordset Dim CurConn As ADODB.Connection Dim strSQL As String Dim strCheckNo As Long Dim strEnglish As String Dim curAmount As Currency Set CurrConn = CurrentProject.Connection strCheckNo = Me.txtStartingCheckNumber strSQL = "SELECT * from tblChecksPendingPrint" rstTemp.Open "tblcheckspendingpring", CurrConn, adOpenDynamic, adLockOptimistic, adCmdTable rstTemp.Source = strSQL rstTemp.MoveFirst Do Until rstTemp.EOF chkNumber = strCheckNo chkPrintDate = Date curAmount = chkAmount.Value strEnglish = DollarsAndCents(curAmount) chkAmountEnglish = strEnglish strCheckNo = strCheckNo + 1 rstTemp.MoveNext Loop rstTemp.Close Set rstTemp = Nothing End Sub Thanks |
|
#2
|
|||
|
|||
|
Not that it matters too much, but are you using Visual Basic or ASP?
|
|
#3
|
|||
|
|||
|
Access 2003
Quote:
|
|
#4
|
|||
|
|||
|
Access 2003
|
|
#5
|
|||
|
|||
|
Try this:
Code:
rstTemp.Open strSQL, CurrConn, adOpenDynamic, adLockOptimistic, adCmdTable You're trying to set the recordset's source after already trying to open it with a different source. Quote:
|
|
#6
|
|||
|
|||
|
Attempted code change, get same error pointing at:
rstTemp.Open strSQL, CurrConn, adOpenDynamic, adLockOptimistic, adCmdTable object variable or with block not set I'm stumped appreciate any help...been doing alot of reading...hasn't helped any. HELP!!! |
|
#7
|
|||
|
|||
|
I'm looking into it but I believe you need to open the connection before using it for the recordset.
Use: Code:
CurrConn.Open rstTemp.Open strSQL, CurrConn, adOpenDynamic, adLockOptimistic, adCmdTable |
|
#8
|
|||
|
|||
|
Operation is not allowed when the object is open
I appreciate your help...Still reading on my side...can't figure it out! |
|
#9
|
|||
|
|||
|
I'm not sure if this makes a huge difference but I forgot to change one parameter for the .Open method earlier.
rstTemp.Open strSQL, CurrConn, adOpenDynamic, adLockOptimistic, adCmdTable The last option should be adCmdText instead of adCmdTable. With adCmdTable, it thinks that strSQL is a table name, not a SQL statement. I'm sorry about the un-helpful posts earlier. The majority of my ado experience has been with vb6 and ASP. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Help with ADO... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|