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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]Call a Public Sub or Function[/b]

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
0
0
US
I want to be able to create a Public Sub or Function which will simply move to a particular control when called. The control will be the same regardless of when it is run, so the code would be the same in each case. I want to be able to call the function or procedure with the update event of several different controls. Basically, I want to end up at this particular control, regardless of which control I update or leave last (of a group of specified controls on the same form).[/b/ The reason is that I have different tabs set up, and I want the last control on the tab to to to what I have designated as the next control in tabbing. I did the code for one control to go to it, but thought it would be best to use it in a Public procedure or function, and just call the procedure or function. Here is the code for one control... any ideas?
Private Sub Weekend_AfterUpdate()
Dim strControl As String
strControl = "cmbFDCPA"
DoCmd.GoToControl strControl
End Sub
 
Public Sub procGoToControl(strForm As String, strControl)
DoCmd.GoToControl Forms(strForm).Controls(strControl).Name
End Sub


from form:

'<code>'
Call procGoTokControl("Form1","Control1") 'will take you to Form1's Control1
'<code>'

Is that what you were looking for?
 
Looks like it. I'll try it tomorrow. Thanks a bunch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top