Not saving to my table???

smelly

Registered User.
Local time
Today, 22:19
Joined
May 23, 2002
Messages
44
Hello,
I am trying to use a check box on exit function to open a table, add a new record, save the Lab ID in this new record, and close the table. But when I run it I get nothing in my table. Help please!
Private Sub Ctl6_Functional_Groups___Enum_Diversity_Exit(Cancel As Integer)
Dim BBCNum As Long
If Me.[6 Functional Groups - Enum+Diversity] = True & Me.MATRIX <> Aq Or CT = True Then
BBCNum = Me.BBCID
DoCmd.OpenTable "Table1a", acViewNormal
DoCmd.GoToRecord , , acNewRec
[Forms]![Table1a].[LAB ID] = BBCNum
DoCmd.Close acForm, "Table1a"
End If

End Sub
 
Last edited:
You really need to do some reading on field naming first, yours is going to cause you no end of problems.
According to your post your trying to add a record to a table but your adding one to a form, what exactly are you trying to do, is this really the name of your field 6 Functional Groups - Enum+Diversity?
 
There's lots wrong with the code starting with the approach. Look up the AddNew method and use the example that you find there.
 
Ok. I made some changes and can see that I was way off on my code. Here is my new code, is this a bit better? It still doesn't work but am I on the right track here? I am getting an error message "can't find the field '|' referred to in your expression" and it refers to Table1a.AddNew.
Thanks! (This is my first encounter with both Access and VB)

Private Sub checkbox1_Exit(Cancel As Integer)
Dim BBCNum As Long
If Me.[checkbox1] = True And Me.MATRIX <> Aq Or CT = True Then
BBCNum = Me.BBCID
DoCmd.OpenTable "Table1a", acViewNormal
Table1a.AddNew
Table1a![LAB ID] = BBCNum
Table1a.Update
Table1a.Close
End If
End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom