R
Robert T
Someone in this forum helped me design a script that stepped through
tblStudents and gave each student a unique Student_ID number [text field]. I
put the script behind a command button on a form and it worked perfectly.
Now one of our students designed a table with almost 800 companies. She
created a TEXT field called Company_ID and wants Access 2003 to step through
each record, assign a unique 4-digit Company_ID, and then move to the next
record, assign the next Company_ID, etc.
Unfortunately we can't get to meat of the script because the script fails at
the
Set cn = CurrentProject.AccessConnection line.
Can someone please advise why the script stops dead in it's tracks at this
line.
Thanks,
Robert
Here's the first 3 lines in the script.
Private Sub Update_ID()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim intMax As Integer
Dim strID As String
Set cn = CurrentProject.AccessConnection
Set rs = New ADODB.Recordset
intMax = DMax("studentid", "tblStudents")
tblStudents and gave each student a unique Student_ID number [text field]. I
put the script behind a command button on a form and it worked perfectly.
Now one of our students designed a table with almost 800 companies. She
created a TEXT field called Company_ID and wants Access 2003 to step through
each record, assign a unique 4-digit Company_ID, and then move to the next
record, assign the next Company_ID, etc.
Unfortunately we can't get to meat of the script because the script fails at
the
Set cn = CurrentProject.AccessConnection line.
Can someone please advise why the script stops dead in it's tracks at this
line.
Thanks,
Robert
Here's the first 3 lines in the script.
Private Sub Update_ID()
Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim intMax As Integer
Dim strID As String
Set cn = CurrentProject.AccessConnection
Set rs = New ADODB.Recordset
intMax = DMax("studentid", "tblStudents")