H
Hunter57
I am designing (as a public service) a database for a client who wants a lot
of text boxes on a form to help him set up colleges class schedules. There
are 7 textboxes that go with each ComboBox. I am using the ComboBox query to
autopopulate the TextBoxes. I have everything pretty well set up except for a
custom function I am trying to create to save a lot of redundant coding in a
form module. I do not have much experience with custom functions and would
appreciate some help. Here is what I have so far:
In the Form Module:
Private Sub cboClassIDMIV_AfterUpdate()
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
Dim myStr As String
myStr = "MIV"
Call FillTxtBoxes(strControlName, myStr)
End Sub
In a Module I named GlobalCode:
Public Function FillTxtBoxes(strControlName As Control.Name, myStr As String)
Forms!Schedule1![txtBatches '" & myStr & "'"] = strControlName.Column(1)
Forms!Schedule1![txtSubject '" & myStr & "'"] = strControlName.Column(2)
Forms!Schedule1![txtClassType '" & myStr & "'"] = strControlName.Column(3)
Forms!Schedule1![txtTeacher '" & myStr & "'"] = strControlName.Column(4)
Forms!Schedule1![txtVenue '" & myStr & "'"] = strControlName.Column(5)
Forms!Schedule1![txtPeriod '" & myStr & "'"] = strControlName.Column(6)
Forms!Schedule1![txtDay '" & myStr & "'"] = strControlName.Column(7)
End Function
I have tried various things but I keep getting error messages concerning the
syntax of the strControlName Variable in the Function.
Also, I am looking for a way to trim the first 10 letters off of the
ComboBox name so I can use the rest of the name to pass on as a variable to
add to the textbox names as the "myStr" Variable and save more time.
Thanks in advance,
Hunter57
of text boxes on a form to help him set up colleges class schedules. There
are 7 textboxes that go with each ComboBox. I am using the ComboBox query to
autopopulate the TextBoxes. I have everything pretty well set up except for a
custom function I am trying to create to save a lot of redundant coding in a
form module. I do not have much experience with custom functions and would
appreciate some help. Here is what I have so far:
In the Form Module:
Private Sub cboClassIDMIV_AfterUpdate()
Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
Dim myStr As String
myStr = "MIV"
Call FillTxtBoxes(strControlName, myStr)
End Sub
In a Module I named GlobalCode:
Public Function FillTxtBoxes(strControlName As Control.Name, myStr As String)
Forms!Schedule1![txtBatches '" & myStr & "'"] = strControlName.Column(1)
Forms!Schedule1![txtSubject '" & myStr & "'"] = strControlName.Column(2)
Forms!Schedule1![txtClassType '" & myStr & "'"] = strControlName.Column(3)
Forms!Schedule1![txtTeacher '" & myStr & "'"] = strControlName.Column(4)
Forms!Schedule1![txtVenue '" & myStr & "'"] = strControlName.Column(5)
Forms!Schedule1![txtPeriod '" & myStr & "'"] = strControlName.Column(6)
Forms!Schedule1![txtDay '" & myStr & "'"] = strControlName.Column(7)
End Function
I have tried various things but I keep getting error messages concerning the
syntax of the strControlName Variable in the Function.
Also, I am looking for a way to trim the first 10 letters off of the
ComboBox name so I can use the rest of the name to pass on as a variable to
add to the textbox names as the "myStr" Variable and save more time.
Thanks in advance,
Hunter57