ScriptHam
08-09-2005, 08:29 AM
Hi :hi:
I am experiencing problems with an unbound form. The form, frmTestQuery, deals with table tblBatchCardGeneral in CompositionWT.mdb
I have a large maintenance job due and wish to do it programmatically rather than amend 120+ records manually.
Initially I will define a SELECT query until I am happy with the result and then move to Action Query strings.
Have obtained this error though not at present, 2147352567 error for the NextRecord command button.
Running Access 2003 on Windows XP installed on a pc networked over a LAN powered by ms NTserver 2003 using SBS.
Option Compare Database
Option Explicit
'Dim remoteConnection As New ADODB.Connection
'Dim rsProducts As New ADODB.Recordset
Private Sub Form_Load()
Dim db As Database 'was As DAO.Database
Dim rsProducts As Recordset 'was As DAO.Recordset
'Dim qdf As QueryDef
Set db = CurrentDb
'Set qdf = "SELECT * FROM tblBatchCardGeneral"
Set rsProducts = db.OpenRecordset("tblBatchCardGeneral")
'Set rs = qdfParmQry.OpenRecordset(qdf)
If (rsProducts.BOF And rsProducts.EOF) Then
MsgBox "Recordset is empty"
End If
Me.txtCount = rsProducts.RecordCount
End Sub
Private Sub cmdStart0_Click() ' Other Command Buttons for navigation are similar
On Error GoTo Err_cmdStart0_Click
Dim db As Database
Dim rsProducts As Recordset
Dim qryStr As String
Set db = CurrentDb
'Set qryStr = "SELECT * FROM tblBatchCardGeneral"
Set rsProducts = db.OpenRecordset("tblBatchCardGeneral")
rsProducts.MoveFirst
Me.txtBCGProductName = rsProducts!ProductName
Rem DoCmd.GoToRecord , , acFirst
Exit_cmdStart0_Click:
Exit Sub
Err_cmdStart0_Click:
MsgBox "There was an error retrieving data from the database" & Err.Number & ", " & Err.Description
Resume Exit_cmdStart0_Click
End Sub
This gives a record count of 126 which is correct but only navigates through 2 records. There are buttons on the form for firstl, last, pervious, next, all with very similar code.
Can anyone see why I can't navigate through this recordset?
I don't know whether I need to Connect to the database, I should have thought not as there is evidence of a connection (counting the records in the table) with the code as it is and also I initialise using
Set db = Currentdb
Any ideas?
If I use Set rsProducts = db.OpenRecordset("tblBatchCardGeneral") I get more progress than
Set rsProducts = db.OpenRecordset("SELECT * FROM tblBatchCardGeneral")
And more also than
Set strSQL = "SELECT * FROM tblBatchCardGeneral"
Set rsProducts = db.OpenRecordset(strSQL)
I am used to finishing an SQL string with ; but this seems to be unnecessary, right or wrong in your opinion?
Can anyone shed any light on why this is happening?
:help
I look forward to hearing from you.
ScriptHam
I am experiencing problems with an unbound form. The form, frmTestQuery, deals with table tblBatchCardGeneral in CompositionWT.mdb
I have a large maintenance job due and wish to do it programmatically rather than amend 120+ records manually.
Initially I will define a SELECT query until I am happy with the result and then move to Action Query strings.
Have obtained this error though not at present, 2147352567 error for the NextRecord command button.
Running Access 2003 on Windows XP installed on a pc networked over a LAN powered by ms NTserver 2003 using SBS.
Option Compare Database
Option Explicit
'Dim remoteConnection As New ADODB.Connection
'Dim rsProducts As New ADODB.Recordset
Private Sub Form_Load()
Dim db As Database 'was As DAO.Database
Dim rsProducts As Recordset 'was As DAO.Recordset
'Dim qdf As QueryDef
Set db = CurrentDb
'Set qdf = "SELECT * FROM tblBatchCardGeneral"
Set rsProducts = db.OpenRecordset("tblBatchCardGeneral")
'Set rs = qdfParmQry.OpenRecordset(qdf)
If (rsProducts.BOF And rsProducts.EOF) Then
MsgBox "Recordset is empty"
End If
Me.txtCount = rsProducts.RecordCount
End Sub
Private Sub cmdStart0_Click() ' Other Command Buttons for navigation are similar
On Error GoTo Err_cmdStart0_Click
Dim db As Database
Dim rsProducts As Recordset
Dim qryStr As String
Set db = CurrentDb
'Set qryStr = "SELECT * FROM tblBatchCardGeneral"
Set rsProducts = db.OpenRecordset("tblBatchCardGeneral")
rsProducts.MoveFirst
Me.txtBCGProductName = rsProducts!ProductName
Rem DoCmd.GoToRecord , , acFirst
Exit_cmdStart0_Click:
Exit Sub
Err_cmdStart0_Click:
MsgBox "There was an error retrieving data from the database" & Err.Number & ", " & Err.Description
Resume Exit_cmdStart0_Click
End Sub
This gives a record count of 126 which is correct but only navigates through 2 records. There are buttons on the form for firstl, last, pervious, next, all with very similar code.
Can anyone see why I can't navigate through this recordset?
I don't know whether I need to Connect to the database, I should have thought not as there is evidence of a connection (counting the records in the table) with the code as it is and also I initialise using
Set db = Currentdb
Any ideas?
If I use Set rsProducts = db.OpenRecordset("tblBatchCardGeneral") I get more progress than
Set rsProducts = db.OpenRecordset("SELECT * FROM tblBatchCardGeneral")
And more also than
Set strSQL = "SELECT * FROM tblBatchCardGeneral"
Set rsProducts = db.OpenRecordset(strSQL)
I am used to finishing an SQL string with ; but this seems to be unnecessary, right or wrong in your opinion?
Can anyone shed any light on why this is happening?
:help
I look forward to hearing from you.
ScriptHam