G
Guest
I am trying to use a field in a query to fill a txtfield when I open a form.
The txtbox is 'txtMaxRecordIntblEMEARepairs' I have a query
'qryMaxRepairRecord' that is simply looking at a table and finding the max
value in a field called 'fldRepairRecordNumber' which is an Auto number. I
have used the following code before, also "on Open' event of form, and no
problem. Now I am getting an error 3265, " Item cannot be found in the
collection correesponding to the requested name or Ordinal".
I am sure the txtname and fldname are correct.
What am I doing wrong.
'Opening Connection, set Variables, Open Table
Dim Conn As ADODB.Connection
Dim rst As ADODB.Recordset
Set Conn = New ADODB.Connection
Conn.Open CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "qryMaxRepairRecord", Conn, adOpenStatic, adLockReadOnly
'Move to first record
rst.MoveFirst
Me!txtMaxRecordIntblEMEARepairs = rst!fldRepairRecordNumber
'Close qryMaxRepairRecord
rst.Close
Set rst = Nothing
Set NewConn = Nothing
The txtbox is 'txtMaxRecordIntblEMEARepairs' I have a query
'qryMaxRepairRecord' that is simply looking at a table and finding the max
value in a field called 'fldRepairRecordNumber' which is an Auto number. I
have used the following code before, also "on Open' event of form, and no
problem. Now I am getting an error 3265, " Item cannot be found in the
collection correesponding to the requested name or Ordinal".
I am sure the txtname and fldname are correct.
What am I doing wrong.
'Opening Connection, set Variables, Open Table
Dim Conn As ADODB.Connection
Dim rst As ADODB.Recordset
Set Conn = New ADODB.Connection
Conn.Open CurrentProject.Connection
Set rst = New ADODB.Recordset
rst.Open "qryMaxRepairRecord", Conn, adOpenStatic, adLockReadOnly
'Move to first record
rst.MoveFirst
Me!txtMaxRecordIntblEMEARepairs = rst!fldRepairRecordNumber
'Close qryMaxRepairRecord
rst.Close
Set rst = Nothing
Set NewConn = Nothing