M
mdullni1 via AccessMonster.com
I have a form and subform. The form has a combo box that determines which
dept records to display on the subform. The subform has multiple pages of
controls for editing. This worked fine (editing, moving through records, etc)
until I added another page that has controls which rely on the value of
another control.
I have a textbox whose InputMask depends on whether a checkbox is true or
false. When I run the procedure to set the InputMask, the if checkbox test
sends the code back to form_current. I added a module-level variable that
basically flags form_current if the code is in the set InputMask procedure.
After a lot of trial and error, I got the code to set the InputMask. Now,
the problem is that when I use the built-in navigation to go to the next
record, it returns to the first record. I have walked through code and
watched ID values, the next record is accessed but the form is on the first
record.
(I also have a combobox that controls the rowsource of another combobox)
Why does the If chkbox statement invoke the form_current procedure?
Here is some code:
Private Sub Form_Current()
'*****************************************************************************
'* Sub: Form_Current
*
'* Purpose: Sets backcolor on fields for current record. Sets Current Record
*
'* label to name of current student.
*
'*****************************************************************************
If mblnEmrgPhn_Mask_Set = False And mblnCnty_RowSrc_Set = False Then
Me.lblCrntRcrd.Caption = "Current Record: " & Me.LNm & ", " & Me.FNm & "
" & Me.MNm
mblntabPrsnl_Set = False
mblntabCtzn_Set = False
mblntabAddr_Set = False
mblntabSchl_Set = False
mblntabSOMRqrd_Set = False
If Me!TabCtlGradAdms.Pages(Me!TabCtlGradAdms.value).Name = "tabPrsnl"
Then
Call TabCtlGradAdms_Change
Else
Me.TabCtlGradAdms.Pages(0).SetFocus
End If
End If
End Sub
Private Sub TabCtlGradAdms_Change()
'*****************************************************************************
'* Sub: TabCtlGradAdms_Change
*
'* Purpose: Set the display as each page of the tab gets focus.
*
'*****************************************************************************
Call Set_BckGrnd(True)
Select Case Me!TabCtlGradAdms.Pages(Me!TabCtlGradAdms.value).Name
Case "tabPrsnl"
If mblntabPrsnl_Set = False Then
mblntabPrsnl_Set = True
Call Set_BckGrnd_Color_Lngth(Me.txtLNm, mlngLNm_Lngth, False)
Call Set_BckGrnd_Color_Lngth(Me.txtFNm, mlngFNm_Lngth, False)
Call Set_BckGrnd_Color_Lngth(Me.txtMNm, mlngMNm_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtSSN, mlngSSN_Lngth, False)
Me.txtDOB.SetFocus
Call Set_BckGrnd_Color_DOB(Me.txtDOB.Text)
Me.txtLNm.SetFocus
End If
Case "tabCtzn"
If mblntabCtzn_Set = False Then
mblntabCtzn_Set = True
Call Set_BckGrnd_Color_Visa
Me.cboStID_POB.SetFocus
End If
Case "tabAddr"
If mblntabAddr_Set = False Then
mblntabAddr_Set = True
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddr1, mlngAddr1_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddr2, mlngAddr2_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddrCty, mlngCty_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddrPstl, mlngPstl_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddr1, mlngAddr1_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddr2, mlngAddr2_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddrCty, mlngCty_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddrPstl, mlngPstl_Lngth, True)
Me.txtLclAddr1.SetFocus
End If
Case "tabSchl"
If mblntabSchl_Set = False Then
mblntabSchl_Set = True
Call Set_BckGrnd_Color_Schl(1)
Call Set_BckGrnd_Color_Schl(2)
Call Set_BckGrnd_Color_Schl(3)
Me.cboSchlID_Schl1.SetFocus
End If
Case "tabSOMRqrd"
Call Set_BckGrnd(False)
If mblntabSOMRqrd_Set = False Then
mblntabSOMRqrd_Set = True
Call Set_EmrgPhn_Mask
Call Set_Cnty_RowSrc
Me.cboJHUBldgs.SetFocus
End If
End Select
End Sub
Private Sub Set_EmrgPhn_Mask()
mblnEmrgPhn_Mask_Set = True
If Me!chkEmrgCntctIntl.value = True Then
Me!txtEmrgCntctPhn.InputMask = ""
Else
Me!txtEmrgCntctPhn.InputMask = "(999) 000-0000;;_"
End If
mblnEmrgPhn_Mask_Set = False
End Sub
Private Sub Set_Cnty_RowSrc()
mblnCnty_RowSrc_Set = True
Me.cboRSDCnty.RowSource = "select lngCntyID, strCntyDsc from tblCnty " _
& "where lngStID = " & Nz(Me!cboRSDStID, 0) & " order
by strCntyDsc"
mblnCnty_RowSrc_Set = False
End Sub
Any suggestions will be greatly appreciated.
dept records to display on the subform. The subform has multiple pages of
controls for editing. This worked fine (editing, moving through records, etc)
until I added another page that has controls which rely on the value of
another control.
I have a textbox whose InputMask depends on whether a checkbox is true or
false. When I run the procedure to set the InputMask, the if checkbox test
sends the code back to form_current. I added a module-level variable that
basically flags form_current if the code is in the set InputMask procedure.
After a lot of trial and error, I got the code to set the InputMask. Now,
the problem is that when I use the built-in navigation to go to the next
record, it returns to the first record. I have walked through code and
watched ID values, the next record is accessed but the form is on the first
record.
(I also have a combobox that controls the rowsource of another combobox)
Why does the If chkbox statement invoke the form_current procedure?
Here is some code:
Private Sub Form_Current()
'*****************************************************************************
'* Sub: Form_Current
*
'* Purpose: Sets backcolor on fields for current record. Sets Current Record
*
'* label to name of current student.
*
'*****************************************************************************
If mblnEmrgPhn_Mask_Set = False And mblnCnty_RowSrc_Set = False Then
Me.lblCrntRcrd.Caption = "Current Record: " & Me.LNm & ", " & Me.FNm & "
" & Me.MNm
mblntabPrsnl_Set = False
mblntabCtzn_Set = False
mblntabAddr_Set = False
mblntabSchl_Set = False
mblntabSOMRqrd_Set = False
If Me!TabCtlGradAdms.Pages(Me!TabCtlGradAdms.value).Name = "tabPrsnl"
Then
Call TabCtlGradAdms_Change
Else
Me.TabCtlGradAdms.Pages(0).SetFocus
End If
End If
End Sub
Private Sub TabCtlGradAdms_Change()
'*****************************************************************************
'* Sub: TabCtlGradAdms_Change
*
'* Purpose: Set the display as each page of the tab gets focus.
*
'*****************************************************************************
Call Set_BckGrnd(True)
Select Case Me!TabCtlGradAdms.Pages(Me!TabCtlGradAdms.value).Name
Case "tabPrsnl"
If mblntabPrsnl_Set = False Then
mblntabPrsnl_Set = True
Call Set_BckGrnd_Color_Lngth(Me.txtLNm, mlngLNm_Lngth, False)
Call Set_BckGrnd_Color_Lngth(Me.txtFNm, mlngFNm_Lngth, False)
Call Set_BckGrnd_Color_Lngth(Me.txtMNm, mlngMNm_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtSSN, mlngSSN_Lngth, False)
Me.txtDOB.SetFocus
Call Set_BckGrnd_Color_DOB(Me.txtDOB.Text)
Me.txtLNm.SetFocus
End If
Case "tabCtzn"
If mblntabCtzn_Set = False Then
mblntabCtzn_Set = True
Call Set_BckGrnd_Color_Visa
Me.cboStID_POB.SetFocus
End If
Case "tabAddr"
If mblntabAddr_Set = False Then
mblntabAddr_Set = True
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddr1, mlngAddr1_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddr2, mlngAddr2_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddrCty, mlngCty_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtLclAddrPstl, mlngPstl_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddr1, mlngAddr1_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddr2, mlngAddr2_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddrCty, mlngCty_Lngth, True)
Call Set_BckGrnd_Color_Lngth(Me.txtPrmAddrPstl, mlngPstl_Lngth, True)
Me.txtLclAddr1.SetFocus
End If
Case "tabSchl"
If mblntabSchl_Set = False Then
mblntabSchl_Set = True
Call Set_BckGrnd_Color_Schl(1)
Call Set_BckGrnd_Color_Schl(2)
Call Set_BckGrnd_Color_Schl(3)
Me.cboSchlID_Schl1.SetFocus
End If
Case "tabSOMRqrd"
Call Set_BckGrnd(False)
If mblntabSOMRqrd_Set = False Then
mblntabSOMRqrd_Set = True
Call Set_EmrgPhn_Mask
Call Set_Cnty_RowSrc
Me.cboJHUBldgs.SetFocus
End If
End Select
End Sub
Private Sub Set_EmrgPhn_Mask()
mblnEmrgPhn_Mask_Set = True
If Me!chkEmrgCntctIntl.value = True Then
Me!txtEmrgCntctPhn.InputMask = ""
Else
Me!txtEmrgCntctPhn.InputMask = "(999) 000-0000;;_"
End If
mblnEmrgPhn_Mask_Set = False
End Sub
Private Sub Set_Cnty_RowSrc()
mblnCnty_RowSrc_Set = True
Me.cboRSDCnty.RowSource = "select lngCntyID, strCntyDsc from tblCnty " _
& "where lngStID = " & Nz(Me!cboRSDStID, 0) & " order
by strCntyDsc"
mblnCnty_RowSrc_Set = False
End Sub
Any suggestions will be greatly appreciated.