HELP! How do i enter value from VBA into a field???

  • Thread starter Thread starter murphy
  • Start date Start date
M

murphy

Guest
Hi im trying to create a database for my A level project in which a pupil will take a test through a visual basic/forms interface. If the answers correct then a 1 will be entered into the field for that question if wrong a 0. The problem is when i try to enter the vlaue into the field it comes up with errors! :confused: Do i need to predefine the fields or what? Ive looked in loads of forums and books but cant find anything related. Am i totaly doing this the wrong way? is there an easier way? or do you know what im doing wrong? any help whatsoever would be great! thank you.
The code is shown below:

Private Sub txt1_Enter()

If txt1.Text = "1" Then

Forms![Frm_Test]![count sets 1] = 1
MsgBox "Lets answer the next question!"
Else

Forms![Frm_Test]![count sets 1] = 0
MsgBox "Lets answer the next question!"
End If


End Sub
 
Your code is grossly correct but.....

Avoid spaces in field and control names as this causes a load of headaches. Also Access (unhelpully) names controls the same as the field that populated them so it can get confused on occasions!

Rename your control to txtCount_Sets_1 and see if that makes a difference first (remember to adjust the code as well ;) )

If no joy, I notice you are using the Enter event procedure. What is the process you want to complete on the form?
 

Users who are viewing this thread

Back
Top Bottom