pages within a control

2ippy

Newbie Here, Be gentle.
Local time
Today, 00:27
Joined
Nov 10, 2006
Messages
78
I want to use a button to goto new record and also goto page 0 within a control so you get to the start of the fields for this data entry.

No help in macro so i was wondering how would i do it in VBA?
 
1.

application runcommand accmdgotonewrecord

2.

mytab.page("page 0").setfocus (might be mytab.pages)
 
Code:
Private Sub CreateNewCustomer_Click()
application runcommand accmdgotonewrecord
    TabCtl58.Page("page 0").SetFocus
End Sub

it doesn't like that application line, so i'm newbie :P
 
Change:
Code:
application runcommand accmdgotonewrecord
TabCtl58.Page("page 0").SetFocus
to this:
Code:
Docmd.RunCommand acCmdGoToNewRecord
Me.tabYourTabControlName.Pages("WhateverYourTabNameIsHere").SetFocus
 
Code:
Private Sub CreateNewCustomer_Click()
    DoCmd.RunCommand acCmdGoToNewRecord
    Me.TabCtl58.Pages("Customers").SetFocus
End Sub

Run-time error '2501'
The RunCommand was canceled.

be gentle :o
 
You may have to set the focus first and then the new record.
 
yeah fucus wasn't the prob so it don't matter about order.

Code:
DoCmd.RunCommand acCmdGoToNewRecord

same error.
 
genius me :P I fixed it.

Code:
DoCmd.RunCommand acCmdRecordsGoToNew

come up with a new bug though. If i'm already on a new record and run this then i get a error.

I know i need.. if record = new - do nothing.. else DoCmd.RunCommand acCmdRecordsGoToNew
 
Just put error handling in place to trap for the error number you get when you try to go to a new record while already on a new record. So something like this (at the top of the event):
Code:
On Error GoTo err_handler
at the bottom of the event:
Code:
Exit Sub
err_handler:
If err.Number <> PutWhateverErrorNumberYouGetHere Then
   Msgbox err.Description, vbOkay, err.Number
   Exit Sub
End If
 
you want the "On Error GoTo err_handler" at the top of the event, but the error handler itself at the bottom of the event, just after your other code.
 
lmao i was messing with tonnes of of combinations and yet it's so simple :D

edit: tyvm
 
Last edited:

Users who are viewing this thread

Back
Top Bottom