S
Sam
Hi,
On the form itself, there is a setting that I'm trying to capture.
(txtTmember = Total family members) I need the ability to allow the user to
add new records for the family and come back with an error when txtTmembers
reaches zero. Only if they happened to hit the NEXT button and all members
have been added. I know a little VB and just learning VBA.
Private Sub cmdNEXT_Click()
Dim txtTmembers As Long 'Capture value in form txtTmembers
Dim members As Long 'Set temp var
txtTmembers = members 'Move that value to members
members = members - 1 'Form default is '1'. adjusting
If members > 0 Then
Do Until members <= 0
members = members - 1 'Countdown
DoCmd.GoToRecord , , acNewRec = acNext 'Create new record
Loop
Else
MsgBox "Warning: " & "Total members of the family have been added." & _
& vbNewLine &_
"To create a New Member record for a NEW Family, " & _
& vbNewLine & _
"please click on 'New Member' button at the top of the form."
End If
End Sub
No errors are generated but the msgbx is always displayed regardless of
txtTmembers value. I don't think I'm capturing the value in txtTmembers. If
this is correct, who do I reference it correctly? Or is there something else
wrong? Thanks for any feedback.
On the form itself, there is a setting that I'm trying to capture.
(txtTmember = Total family members) I need the ability to allow the user to
add new records for the family and come back with an error when txtTmembers
reaches zero. Only if they happened to hit the NEXT button and all members
have been added. I know a little VB and just learning VBA.
Private Sub cmdNEXT_Click()
Dim txtTmembers As Long 'Capture value in form txtTmembers
Dim members As Long 'Set temp var
txtTmembers = members 'Move that value to members
members = members - 1 'Form default is '1'. adjusting
If members > 0 Then
Do Until members <= 0
members = members - 1 'Countdown
DoCmd.GoToRecord , , acNewRec = acNext 'Create new record
Loop
Else
MsgBox "Warning: " & "Total members of the family have been added." & _
& vbNewLine &_
"To create a New Member record for a NEW Family, " & _
& vbNewLine & _
"please click on 'New Member' button at the top of the form."
End If
End Sub
No errors are generated but the msgbx is always displayed regardless of
txtTmembers value. I don't think I'm capturing the value in txtTmembers. If
this is correct, who do I reference it correctly? Or is there something else
wrong? Thanks for any feedback.