Access 2010 "Navigation Form" VBA code to Click a tab (1 Viewer)

AOSB

Registered User.
Local time
Yesterday, 19:01
Joined
Sep 12, 2011
Messages
18
I have what Microsoft call a "Navigation Form" as the main form in my application. Users just click tabs to move about the application and it all works very well, looks good and was almost no work to produce.
Now one of the forms that opens when you click a tab shows a summary of overdue matters ie a continuous form of a few fields from a record in text boxes. The boxes are populated from a query that pulls out those records that are overdue for attention.
Ideally there should be a button beside the text boxes and when one is clicked it should open a form where the updating of information is needed. This happens to be the form that is opened by the second tab in the "Navigation Form".
So the VBA code behind such a button needs to be along the lines (in Psuedo VBA) of :-

Global VarID as integer 'In a Module
'and then
Sub Button1_Click
VarID = Me.ID
Click (navigation form.tab2) ' I hope its as easy as this
End Sub

'and some way of filtering the form with VarID so that it shows the right record.

This baffles me. Over to you O Great Ones!
 

AOSB

Registered User.
Local time
Yesterday, 19:01
Joined
Sep 12, 2011
Messages
18
OK I am halfway there. I find that you can achieve the result I am looking for with a Browseto embedded macro. The syntax is hellish but I now click the button and the right form opens up in the Navigation Form Frame. I really cant figure out how to get the Criteria syntax right so the correct record is shown. any assistance will be appreciated.
Browseto
object Name frmBrowseTestators
Object type Form
Path to subformControl frmNavigation.NavigationSubform
Where condition = ID = txtTID

Only the last line is wrong. txtTID is a textbox with a number in it on the form with the button which runs the macro. If I hard code the macro to ID = 3 or something it works. If the txtTID box has a 3 in it and I press the button it just opens the first record.
 

AOSB

Registered User.
Local time
Yesterday, 19:01
Joined
Sep 12, 2011
Messages
18
Its not really like that in 2010. The Wizard opens an embedded macro sheet to fill in. A screen shot is attached. The Where Condition is wrong, I am still trying to work it out. But you make me think - perhaps I can scrap the embedded macro and put an On Click event in for the button instead. The syntax might be simpler. After some Googling I think its probably

DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmTestator", _
PathToSubformControl:="[frmNavigation].[NavigationSubform]", _
WhereCondition:="???????????", _
Page:="", _
DataMode:=acReadOnly

Your post may help me decide what to put in the WhereCondition
I'll give it a try when I get home. Thanks for your input.
 

Attachments

  • AC.jpg
    AC.jpg
    14.1 KB · Views: 1,171

AOSB

Registered User.
Local time
Yesterday, 19:01
Joined
Sep 12, 2011
Messages
18
Solved!

Private Sub btnGo_Click()
DoCmd.BrowseTo ObjectType:=acBrowseToForm, _
ObjectName:="frmBrowseTestators", _
PathToSubformControl:="frmNavigation.NavigationSubform", _
WhereCondition:="ID = " & txtTID, _
Page:="", _
DataMode:=acReadOnly
End Sub

Does the trick. The lesson seems to be 'steer clear of embedded macros'.

Thanks for the steer to VbaInet
 

AOSB

Registered User.
Local time
Yesterday, 19:01
Joined
Sep 12, 2011
Messages
18
I pasted the code in and this editor inserted a space between Navigationsub and Form. This space is obviously not required.
 

Users who are viewing this thread

Top Bottom