sorenwrang
New member
- Local time
- Today, 23:11
- Joined
- Jan 10, 2014
- Messages
- 3
Hello
I am trying to do some simple table operations. I have a field (Date) containing dates, and an empty field called Day.
I want to extract the day number from the Date field, and write it to the Day field.
I didn't get very far until I ran into trouble when setting my recordset. I get the error "Too few parameters, expected 1". Clicking "Debug", will highlight the code line "Set rs = db.OpenRecordset(sqlString, dbOpenDynaset)".
So far, my code looks as follows:
I don't really see my mistake.
Please note, that I am not very familiar with the various types of recordset settings. I just want to be able to read data from the Date field, and write data to the Day field.
I am trying to do some simple table operations. I have a field (Date) containing dates, and an empty field called Day.
I want to extract the day number from the Date field, and write it to the Day field.
I didn't get very far until I ran into trouble when setting my recordset. I get the error "Too few parameters, expected 1". Clicking "Debug", will highlight the code line "Set rs = db.OpenRecordset(sqlString, dbOpenDynaset)".
So far, my code looks as follows:
Code:
Private Sub Command16_Click()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim sqlString As String
Dim dataDay As Byte
'Open connection to current Access database
Set db = CurrentDb()
'Create SQL statement
sqlString = "SELECT Date,Day FROM MovesOverview_vessel"
Set rs = db.OpenRecordset(sqlString, dbOpenDynaset)
Do Until rs.EOF
dataDay = Format(rs!Date, "dd")
rs.MoveNext
Loop
rs.Close
End Sub
I don't really see my mistake.
Please note, that I am not very familiar with the various types of recordset settings. I just want to be able to read data from the Date field, and write data to the Day field.