My DB is almost complete except for this code.
Private Sub Form_Current()
Dim one As String
Dim Two As String
one = Me.Text5.Value
If Me.Text5.Value = True Then
Me.main.Value = one
one = "0" 'Thought this would clear the value of one????
Else
Me.main.Value = "0"
End If
End Sub
'code resides behind sub form
It works fine until I try to add a new record. The form is linked to a query so the value of the text can grab the info that it needs from the main table. It would probably help if I told you that this is to grab the primary key from the main table and update it automaticaly to this form when the cmd button is clicked to bring the user to the secondary form (data for both forms are from 2 diff tables). (Hope that is not to confusing). The error that is generated is from Access and not VB. If the new record is saved and the form is shut down then the secondary form saves the fields info. to the table but once a new record is entered in the main form and the cmd clicked it will not work generating the error "You can not add or change the data because a related record is required in the main table" Now why would this happen if the records stored are the same and are not changing? The DB is in 3rd normal form, however when I delete the relationships it works everytime. Any Help would be greatly appreciated. Sorry in advance if my question is to confusing.
Private Sub Form_Current()
Dim one As String
Dim Two As String
one = Me.Text5.Value
If Me.Text5.Value = True Then
Me.main.Value = one
one = "0" 'Thought this would clear the value of one????
Else
Me.main.Value = "0"
End If
End Sub
'code resides behind sub form
It works fine until I try to add a new record. The form is linked to a query so the value of the text can grab the info that it needs from the main table. It would probably help if I told you that this is to grab the primary key from the main table and update it automaticaly to this form when the cmd button is clicked to bring the user to the secondary form (data for both forms are from 2 diff tables). (Hope that is not to confusing). The error that is generated is from Access and not VB. If the new record is saved and the form is shut down then the secondary form saves the fields info. to the table but once a new record is entered in the main form and the cmd clicked it will not work generating the error "You can not add or change the data because a related record is required in the main table" Now why would this happen if the records stored are the same and are not changing? The DB is in 3rd normal form, however when I delete the relationships it works everytime. Any Help would be greatly appreciated. Sorry in advance if my question is to confusing.