EmmaLawton
Member
- Joined
- Jun 9, 2004
- Messages
- 5
- Programming Experience
- 5-10
I have a form with 3 frames with numerous text boxes and combo boxes on them.
My code loops through each control on each frame on the form and captures the value of the text property of each textbox. Except that for all but 2 of the textboxes, the value of the text property is an empty string, irrespective of what the user has input into the textbox.
Here is the code...
PrivateSub CaptureScreen(ByRef rarySQLFields(,), _
ByRef raryOraFields(,))
Dim ctrl As Control
Dim grpctrl As Control
Dim intPos AsInteger
ReDim rarySQLFields(18, 1)
Try
ForEach ctrl InMe.Controls
If ctrl.GetType.Name = "GroupBox" Then
ForEach grpctrl In ctrl.Controls
SelectCase grpctrl.GetType.Name
Case "TextBox"
SelectCase grpctrl.Name
Case "txtFEID"
rarySQLFields(2, 0) = grpctrl.Text
rarySQLFields(2, 1) = "@FE"
Case "txtRMGRef"
rarySQLFields(4, 0) = grpctrl.Text
rarySQLFields(4, 1) = "@ClientRef"
Case "txtCName"
rarySQLFields(12, 0) = grpctrl.Text
rarySQLFields(12, 1) = "@Name"
Case "txtCWork"
rarySQLFields(14, 0) = grpctrl.Text
rarySQLFields(14, 1) = "@POW"
Case "txtCOcc"
rarySQLFields(13, 0) = grpctrl.Text
rarySQLFields(13, 1) = "@Occupation"
Case "txtCAccidentDt"
If grpctrl.Text <> "" Then
rarySQLFields(15, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(15, 0) = ""
EndIf
rarySQLFields(15, 1) = "@AccidentDate"
Case "txtCNature" 'nature of accident
rarySQLFields(16, 0) = grpctrl.Text
rarySQLFields(16, 1) = "@AccidentNature"
Case "txtType" 'type of injury
rarySQLFields(17, 0) = grpctrl.Text
rarySQLFields(17, 1) = "@Injury"
Case "txtPCode"
rarySQLFields(18, 0) = grpctrl.Text
rarySQLFields(18, 1) = "@PostCode"
Case "txtBPRef"
rarySQLFields(11, 0) = grpctrl.Text
rarySQLFields(11, 1) = "@BPRef"
Case "txtCSettlementDt"
If grpctrl.Text <> "" Then
rarySQLFields(10, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(10, 0) = ""
EndIf
rarySQLFields(10, 1) = "@SettlementDate"
Case "txtClosedDt"
If grpctrl.Text <> "" Then
rarySQLFields(9, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(9, 0) = ""
EndIf
rarySQLFields(9, 1) = "@ClosedDate"
Case "txtOpenedDt"
If grpctrl.Text <> "" Then
rarySQLFields(8, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(8, 0) = ""
EndIf
rarySQLFields(8, 1) = "@OpenedDate"
CaseElse
Debug.WriteLine("Missed " & grpctrl.Name)
EndSelect
Case "ComboBox"
SelectCase grpctrl.Name
Case "cboClientID"
If IsNothing(raryOraFields) Then
ReDim raryOraFields(1, 1)
Else
intPos = GetPosition(raryOraFields)
If intPos < 0 Then
Err.Raise(999, "frmDetails.CaptureScreen", "Error gather search criteria")
EndIf
EndIf
raryOraFields(intPos, 0) = grpctrl.Text
raryOraFields(intPos, 1) = "CLIENT_MATTER.CLIENT_ID"
rarySQLFields(1, 0) = CInt(grpctrl.Text)
rarySQLFields(1, 1) = "@ClientID"
Case "cboMatterNum" '0
If IsNothing(raryOraFields) Then
ReDim raryOraFields(1, 1)
Else
intPos = GetPosition(raryOraFields)
If intPos < 0 Then
Err.Raise(999, "frmDetails.CaptureScreen", "Error gather search criteria")
EndIf
EndIf
raryOraFields(intPos, 0) = grpctrl.Text
raryOraFields(intPos, 1) = "CLIENT_MATTER.MATTER_NUM"
rarySQLFields(0, 0) = grpctrl.Text
rarySQLFields(0, 1) = "@MatterNum"
Case "cboClass"
rarySQLFields(6, 0) = grpctrl.Text
rarySQLFields(6, 1) = "@ClassCode"
Case "cboBCodes"
rarySQLFields(5, 0) = grpctrl.Text
rarySQLFields(5, 1) = "@BudgetCode"
Case "cboClientName"
rarySQLFields(3, 0) = grpctrl.Text
rarySQLFields(3, 1) = "@RMGClient"
CaseElse
Debug.WriteLine("Missed " & grpctrl.Name)
EndSelect
Case "NumericUpDown"
rarySQLFields(7, 0) = nudProbability.Value
rarySQLFields(7, 1) = "@Probability"
EndSelect
Next grpctrl
EndIf
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
EndTry
EndSub
I've run out of time on my project and need to resolve this issue ASAP. Has anyone experienced anything similar?
Many Thanks
My code loops through each control on each frame on the form and captures the value of the text property of each textbox. Except that for all but 2 of the textboxes, the value of the text property is an empty string, irrespective of what the user has input into the textbox.
Here is the code...
PrivateSub CaptureScreen(ByRef rarySQLFields(,), _
ByRef raryOraFields(,))
Dim ctrl As Control
Dim grpctrl As Control
Dim intPos AsInteger
ReDim rarySQLFields(18, 1)
Try
ForEach ctrl InMe.Controls
If ctrl.GetType.Name = "GroupBox" Then
ForEach grpctrl In ctrl.Controls
SelectCase grpctrl.GetType.Name
Case "TextBox"
SelectCase grpctrl.Name
Case "txtFEID"
rarySQLFields(2, 0) = grpctrl.Text
rarySQLFields(2, 1) = "@FE"
Case "txtRMGRef"
rarySQLFields(4, 0) = grpctrl.Text
rarySQLFields(4, 1) = "@ClientRef"
Case "txtCName"
rarySQLFields(12, 0) = grpctrl.Text
rarySQLFields(12, 1) = "@Name"
Case "txtCWork"
rarySQLFields(14, 0) = grpctrl.Text
rarySQLFields(14, 1) = "@POW"
Case "txtCOcc"
rarySQLFields(13, 0) = grpctrl.Text
rarySQLFields(13, 1) = "@Occupation"
Case "txtCAccidentDt"
If grpctrl.Text <> "" Then
rarySQLFields(15, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(15, 0) = ""
EndIf
rarySQLFields(15, 1) = "@AccidentDate"
Case "txtCNature" 'nature of accident
rarySQLFields(16, 0) = grpctrl.Text
rarySQLFields(16, 1) = "@AccidentNature"
Case "txtType" 'type of injury
rarySQLFields(17, 0) = grpctrl.Text
rarySQLFields(17, 1) = "@Injury"
Case "txtPCode"
rarySQLFields(18, 0) = grpctrl.Text
rarySQLFields(18, 1) = "@PostCode"
Case "txtBPRef"
rarySQLFields(11, 0) = grpctrl.Text
rarySQLFields(11, 1) = "@BPRef"
Case "txtCSettlementDt"
If grpctrl.Text <> "" Then
rarySQLFields(10, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(10, 0) = ""
EndIf
rarySQLFields(10, 1) = "@SettlementDate"
Case "txtClosedDt"
If grpctrl.Text <> "" Then
rarySQLFields(9, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(9, 0) = ""
EndIf
rarySQLFields(9, 1) = "@ClosedDate"
Case "txtOpenedDt"
If grpctrl.Text <> "" Then
rarySQLFields(8, 0) = Format(CDate(grpctrl.Text), "mm/dd/yyyy")
Else
rarySQLFields(8, 0) = ""
EndIf
rarySQLFields(8, 1) = "@OpenedDate"
CaseElse
Debug.WriteLine("Missed " & grpctrl.Name)
EndSelect
Case "ComboBox"
SelectCase grpctrl.Name
Case "cboClientID"
If IsNothing(raryOraFields) Then
ReDim raryOraFields(1, 1)
Else
intPos = GetPosition(raryOraFields)
If intPos < 0 Then
Err.Raise(999, "frmDetails.CaptureScreen", "Error gather search criteria")
EndIf
EndIf
raryOraFields(intPos, 0) = grpctrl.Text
raryOraFields(intPos, 1) = "CLIENT_MATTER.CLIENT_ID"
rarySQLFields(1, 0) = CInt(grpctrl.Text)
rarySQLFields(1, 1) = "@ClientID"
Case "cboMatterNum" '0
If IsNothing(raryOraFields) Then
ReDim raryOraFields(1, 1)
Else
intPos = GetPosition(raryOraFields)
If intPos < 0 Then
Err.Raise(999, "frmDetails.CaptureScreen", "Error gather search criteria")
EndIf
EndIf
raryOraFields(intPos, 0) = grpctrl.Text
raryOraFields(intPos, 1) = "CLIENT_MATTER.MATTER_NUM"
rarySQLFields(0, 0) = grpctrl.Text
rarySQLFields(0, 1) = "@MatterNum"
Case "cboClass"
rarySQLFields(6, 0) = grpctrl.Text
rarySQLFields(6, 1) = "@ClassCode"
Case "cboBCodes"
rarySQLFields(5, 0) = grpctrl.Text
rarySQLFields(5, 1) = "@BudgetCode"
Case "cboClientName"
rarySQLFields(3, 0) = grpctrl.Text
rarySQLFields(3, 1) = "@RMGClient"
CaseElse
Debug.WriteLine("Missed " & grpctrl.Name)
EndSelect
Case "NumericUpDown"
rarySQLFields(7, 0) = nudProbability.Value
rarySQLFields(7, 1) = "@Probability"
EndSelect
Next grpctrl
EndIf
Next
Catch ex As Exception
Debug.WriteLine(ex.Message)
EndTry
EndSub
I've run out of time on my project and need to resolve this issue ASAP. Has anyone experienced anything similar?
Many Thanks