whats wrong with this code??? :(:(:(

bella

Registered User.
Local time
Today, 21:22
Joined
Jul 31, 2003
Messages
38
Hi guys its been ages snce i posted, and i am stuck again :(

ive copied a bit of code down, can u tell me whats wrong with it? the error message i get is : Rub time error 3061, Too few parameters, expected 1

when i go to debug it it highlights this line:

Set rstSSC = dbs.OpenRecordset(strSQL)

PLEASE HELP???

sorry if this is a silly question
Bella :confused:
-------------------------------------------------------------------------
Private Sub Command2_Click()

'Write a bit of code that updates student_ID's, and student
'subject selections to the Student_Subject_Connector table

'see code from other update's for this.

' Update TO Student_Subject_Connector Student Code 3000 to 3167 and the corresponding SL_ID's"

'e.g
'Student Code = 3000, 5,6,8,12,13,15,17,18
'Student Code = 3001, 5,6,8,12,13,15,17,18

'1. Select Student Code and SL_ID1 - 10 from Student Subject Connector.
'2. Allocate Year 8 values to Student Code = 3000+1
'3. So student 1 = 3000+1
'4. Get next student and give her 3001 + 1
'THINK !

' Build string to fill in the [Learning Outcomes Connector]

Dim dbs As DAO.Database
Dim rstSSC As DAO.Recordset 'Record set that holds a set of values for student 3000+ x
Dim strSQL As String

Dim x As Integer ' Student Code variable
Dim sub1 As Integer ' subject 1
Dim sub2 As Integer ' subject 2
Dim sub3 As Integer ' subject 3
Dim sub4 As Integer ' subject 4
Dim sub5 As Integer
Dim sub6 As Integer
Dim sub7 As Integer
Dim sub8 As Integer
Dim sub9 As Integer
Dim sub10 As Integer
Dim sub11 As Integer
Dim sub12 As Integer

Set dbs = CurrentDb

strSQL = "SELECT [Student Subject Connector].[Student_Code], [Student Subject Connector].[SL_ID1], " & _
"[Student Subject Connector].[SL_ID2], [Student Subject Connector].[SL_ID3], " & _
"[Student Subject Connector].[SL_ID4], [Student Subject Connector].[SL_ID5], " & _
"[Student Subject Connector].[SL_ID6], [Student Subject Connector].[SL_ID7], " & _
"[Student Subject Connector].[SL_ID8], [Student Subject Connector].[SL_ID9], " & _
"[Student Subject Connector].[SL_ID10], [Student Subject Connector].[SL_ID11], " & _
"[Student Subject Connector].[SL_ID12] " & _
"FROM [Student Subject Connector];"

Set rstSSC = dbs.OpenRecordset(strSQL)

rstSSC.AddNew


' Year 8 starts in 03 so their Student Code is always 3000 + something
x = 3000

' these sub values correspond to th SL_ID's that every kid in year 8 does. i have allocated these by hand.

sub1 = 5
sub2 = 6
sub3 = 8
sub4 = 13
sub5 = 15
sub6 = 17
sub7 = 18
sub9 = 29
sub10 = 35
sub11 = 41
sub12 = 43

'for Student Code 3001 to 3168:
' Set Student Code = x + 1 where x = 3000 (for year 8, because they started in 03)
rstSSC![Student_Code] = x + 1

' Set SL_ID1 value to sub1 (sub1 is the SL_ID of this subject)
rstSSC![SL_ID1] = sub1

' Set SL_ID2 value to sub2 (sub2 is the SL_ID of this subject)
rstSSC![SL_ID2] = sub2

' Set SL_ID3 value to sub3 (sub3 is the SL_ID of this subject)
rstSSC![SL_ID3] = sub3

' Set SL_ID4 value to sub4 (sub4 is the SL_ID of this subject)
rstSSC![SL_ID4] = sub4

' Set SL_ID5 value to sub5 (sub5 is the SL_ID of this subject)
rstSSC![SL_ID5] = sub5

' Set SL_ID6 value to sub6 (sub6 is the SL_ID of this subject)
rstSSC![SL_ID6] = sub6

' Set SL_ID7 value to sub7 (sub7 is the SL_ID of this subject)
rstSSC![SL_ID7] = sub7

' Set SL_ID8 value to sub8 (sub8 is the SL_ID of this subject)
rstSSC![SL_ID8] = sub8

' Set SL_ID9 value to sub9 (sub9 is the SL_ID of this subject)
rstSSC![SL_ID9] = sub9

' Set SL_ID10 value to sub10 (sub10 is the SL_ID of this subject)
rstSSC![SL_ID10] = sub10

' Set SL_ID11 value to sub11 (sub11 is the SL_ID of this subject)
rstSSC![SL_ID11] = sub11

' Set SL_ID12 value to sub12 (sub12 is the SL_ID of this subject)
rstSSC![SL_ID12] = sub12


' Update the loaded recordset to the learning Outcomes Connector table
rstSSC.Update

End Sub
 
What's all this SL_ID1, SL_ID2, SL_IDn rubbish?

That's a repeating group and should be in a table of its own.

For the best results, done simply, and with less (if any) need for future reference: normalise your database!
 

Users who are viewing this thread

Back
Top Bottom