![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I'm having difficulty transferring data entered in forms into the relevant tables of my database. For reasons I'm not going into here I am trying to do it by creating a form in design view with various text boxes on it. I am writing code behind the button to send the data in the text boxes on the form to the fields in the database. The problem I am having is with this code. This is what I expected to work: Private Sub Command4_Click() Dim db As Database Dim rst As Recordset Set db = CurrentDb Set rst = db.OpenRecordset("Employees") 'Employees is the table rst.AddNew Text0.SetFocus 'We have to set focus for each field MsgBox ("Text0=" & Text0.Text) 'Just see what we got rst!FirstName = Text0.Text Text2.SetFocus MsgBox ("Text2=" & Text2.Text) rst!LastName = Text2.Text rst.Update rst.Close End Sub However it won't let me write dim db as database as there is no databse option in the list that drops down. I have also noticed that there is also not a DAO option. I don't understand enough about access to understand why this is. I've tried converting it to different formats, i.e. to access 1997 but these options are still not available. I think I am using Access 2000. I have another database in access 2000 which i wrote a while ago which does have all these options available! Would somebody PLEASE help me I'm tearing my hair out!! Caroline |
#3
| |||
| |||
|
|
I'm having difficulty transferring data entered in forms into the relevant tables of my database. For reasons I'm not going into here I am trying to do it by creating a form in design view with various text boxes on it. I am writing code behind the button to send the data in the text boxes on the form to the fields in the database. The problem I am having is with this code. This is what I expected to work: Private Sub Command4_Click() Dim db As Database Dim rst As Recordset Set db = CurrentDb Set rst = db.OpenRecordset("Employees") 'Employees is the table rst.AddNew Text0.SetFocus 'We have to set focus for each field MsgBox ("Text0=" & Text0.Text) 'Just see what we got rst!FirstName = Text0.Text Text2.SetFocus MsgBox ("Text2=" & Text2.Text) rst!LastName = Text2.Text rst.Update rst.Close End Sub However it won't let me write dim db as database as there is no databse option in the list that drops down. I have also noticed that there is also not a DAO option. I don't understand enough about access to understand why this is. I've tried converting it to different formats, i.e. to access 1997 but these options are still not available. I think I am using Access 2000. I have another database in access 2000 which i wrote a while ago which does have all these options available! Would somebody PLEASE help me I'm tearing my hair out!! Caroline |
#4
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |