Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid qualifier problem.

Status
Not open for further replies.

Petemush

Technical User
Jun 21, 2002
255
GB
I have a form where a lot of the AfterUpdate events are the same and really only the control name changes. I've made a procedure that passes the control being updated and another control that needs to be updated automatically.

All this works fine but I have some other AfterUpdate events that while similar, have extra code. I still want to use the previously made procedure so I added an extra argument (boolean) to be used to indicate whether there is extra code to carry out. This also works fine.

The problem is that the controls (checkboxes) that have extra code make reference to another corresponding control (option group). The controls that don't need extra code do not have a corresponding option group therefore I can't pass the option group as an argument since not all of the controls calling the procedure have an option group to pass.

To get round this, in the extra code part of the procedure I declared a string and managed in a backward way to create the name of the corresponding option group to whatever control had been passed.

Now(phew), how do I reference this control when all I've got is a string with it's location?

Here's the code.


'Enables or disables controls on form frmFindCourses depending on
'the value of the controls corresponding CheckBox.

Public Sub After_Update_Checkboxes(checkbox_name As CheckBox, _
control_name As Control, _
changeCost As Boolean)

Dim tempString As String, tempField As field

'If the CheckBox is ticked...
If checkbox_name = True Then

'...then enable the CheckBox's corresponding control.
control_name.Enabled = True

'If Cost_Type needs to be changed...
If changeCost Then

'...create the corresponding(to the checkbox) option
'group's name.

tempString = checkbox_name.Name
tempString = "[op" & Left(tempString, _
(Len(tempString) - 6) & "]")

tempField.Name = tempString

Form_frmFindCourses!tempField.Enabled = True

If IsNull(Form_frmFindCourses![Cost Type]) Then

Form_frmFindCourses![CostType Check].Value = True
Form_frmFindCourses![Cost Type].Enabled = True
Form_frmFindCourses![Cost Type].Value = "Variable"

End If
End If
Else

'Disable and clear the checkbox's corresponding control.
control_name.Enabled = False
control_name.Value = Null
Form_frmFindCourses!tempField.Enabled = False
Form_frmFindCourses!tempField.Value = 1

End If

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top