OK ... something unusual, in a good way, happened. If we consider what is done with a "service" using service 2 as an example. Completing service one unhides service 2's frame (frm_service), which contains 8 controls, 2 checkboxes, 2 textboxes and 4 comboboxes. All controls with the exception of the two checkboxes (cbx_s2_rln and cbx_s2_chg) are disabled.
1. The user selects one of the two checkboxes. Lets suppose the user checks cbx_s2_rln.
2. The click event will code enable the first textbox, and send focus to it (via Jaafar's method) by way of a common procedure in a standard module (cbx_reline). This works flawlessly ... thecursor is available in the formatted textbox tb_s2_lwr allowing the user to enter a value without having to click anywhere.
3. On tabbing out, the tb_s2_lwr code exit code is supposed to trigger thus enabling the next textbox, tb_s2_upr, formatting it and sending focus to it (via Jaafar's method).
This has not been happening. Focus is being sent to some other textbox outside the frame. The exit code is not being triggered. For the exit code to trigger, the user has to click the tb_s2_upr control.
4After the user has entered their value into tb_s2_upr, tabbing will trigger the beforeupdate code which enables the next control, a combobox, formats it, and sends focus to it (Jaafar's method). This works flawlessly. The cursor is waiting for input by the user without the user having to select the control.
I pretty much gave up, hoping for someone to point out the obvious solution, which I'm fearing there may not be one. So I continued to do some more coding.
I added this code, in blue, to the cbx_reline procedure ...
Rich (BB code):
Sub cbx_reline(ByVal frmservice As Object, index As Integer)
'Stop
If Not mbevents Then Exit Sub
mbevents = False
With frmservice
If .Controls("cbx_s" & index & "_rln").Value = True Then
.Controls("cbx_s" & index & "_chg").Value = False
With .Controls("tb_s" & index & "_lwr")
.Enabled = True
.Value = ""
.BackColor = RGB(206, 234, 232)
End With
.Controls("lbl_s" & index & "_1").Enabled = True
ForceFocus .Controls("tb_s" & index & "_lwr")
.Controls("tb_s" & index & "_lwr").SetFocus
'mbevents = True
Else
'Stop
.Controls("cbx_s" & index & "_chg").Value = False
With .Controls("tb_s" & index & "_lwr")
.Enabled = False
.Value = ""
.BackColor = vbWhite
End With
With .Controls("tb_s" & index & "_upr")
.Enabled = False
.Value = ""
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_crew")
.Enabled = False
.Value = ""
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_div")
.Enabled = False
.Value = ""
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_base")
.Enabled = False
.Value = ""
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_pitch")
.Enabled = False
.Value = ""
.BackColor = vbWhite
End With
For I = 1 To 6
.Controls("lbl_s" & index & "_" & I).Enabled = False
.Controls("lbl_s" & index & "_" & I).BackColor = RGB(0, 128, 128)
Next I
.Controls("cbt_s" & index & "_add").Enabled = False
mbevents = True
Exit Sub
'mbevents = True
End If
For I = 2 To 6
.Controls("lbl_s" & index & "_" & I).Enabled = False
.Controls("lbl_s" & index & "_" & I).BackColor = RGB(0, 128, 128)
Next I
With .Controls("tb_s" & index & "_upr")
.Value = ""
.Enabled = False
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_crew")
.Value = ""
.Enabled = False
.BackColor = vbWhite
End With
If index = 1 Then 'pull reline data from original
With .Controls("cb_s" & index & "_div")
.Value = ws_thold.Cells(1, 27).Value
.Enabled = False
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_pitch")
.Value = ws_thold.Cells(1, 32).Value
.Enabled = False
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_base")
.Value = ws_thold.Cells(1, 31).Value
.Enabled = False
.BackColor = vbWhite
End With
Else 'pull reline data from previous service in core_data
psrvc = index - 1
If psrvc = 1 Then 'from 2
pdiv = ws_cd.Cells(cd_rrow, 41)
pbase = ws_cd.Cells(cd_rrow, 42)
ppitch = ws_cd.Cells(cd_rrow, 43)
ElseIf psrvc = 2 Then 'from 3
pdiv = ws_cd.Cells(cd_rrow, 48)
pbase = ws_cd.Cells(cd_rrow, 49)
ppitch = ws_cd.Cells(cd_rrow, 50)
ElseIf psrvc = 3 Then 'from 4
pdiv = ws_cd.Cells(cd_rrow, 55)
pbase = ws_cd.Cells(cd_rrow, 56)
ppitch = ws_cd.Cells(cd_rrow, 57)
ElseIf psrvc = 4 Then 'from 5
pdiv = ws_cd.Cells(cd_rrow, 62)
pbase = ws_cd.Cells(cd_rrow, 63)
ppitch = ws_cd.Cells(cd_rrow, 64)
ElseIf psrvc = 5 Then 'from 6
pdiv = ws_cd.Cells(cd_rrow, 68)
pbase = ws_cd.Cells(cd_rrow, 69)
ppitch = ws_cd.Cells(cd_rrow, 70)
ElseIf psrvc = 6 Then 'from 7
pdiv = ws_cd.Cells(cd_rrow, 76)
pbase = ws_cd.Cells(cd_rrow, 78)
ppitch = ws_cd.Cells(cd_rrow, 79)
Else 'psrvc = 7 Then from 7
pdiv = ws_cd.Cells(cd_rrow, 83)
pbase = ws_cd.Cells(cd_rrow, 84)
ppitch = ws_cd.Cells(cd_rrow, 85)
End If
With .Controls("cb_s" & index & "_div")
.Value = pdiv
.Enabled = False
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_pitch")
.Value = ppitch
.Enabled = False
.BackColor = vbWhite
End With
With .Controls("cb_s" & index & "_base")
.Value = pbase
.Enabled = False
.BackColor = vbWhite
End With
End If
If index > 1 Then .Controls("cbt_s" & index & "_del").Enabled = True
.Controls("cbt_s" & index & "_add").Enabled = False
'mbevents = True
End With
mbevents = True
End Sub
After adding this code, what wasn't working in step 3 of the process ... is!!! So now, after the user enters a value in tb_s2_rln, and tabs out, the focus and curso goes direct to the next control, tb_s2_upr. Unlike before this code was added, the user does no longer have to click.
This code has nothing to do with any of the controls that take the setfocus needs. I have no idea why this code is making a difference.
That being said, if the user originally selects the alternate checkbox, cbx_s2_chg, the process will function the same way cbx_s2_rln ORIGINALLY did. So, I don't know what to to to the cbx_s2_chg code (that was done to cbx_s2_rln code that got it working)? I can't add that code because it doesn't apply to the data needed for the CHG function.
Based on this new revelation, can anyone offer a solution as to how I can fix cbx_s2_chg?