Buttons on footer to choose next / Previous Records on - SFrm

stu_c

Registered User.
Local time
Today, 06:39
Joined
Sep 20, 2007
Messages
494
Hi all
I have got a main for with a sub form as shown below named below
FrmMainDetails - Main From
SFrmNewOrders - Sub Form From FrmMainDetails
SSFrmBackOrders - Sub Form From SFrmOrders

What I want is a footer on the main from so I can go through the relevant records and not make it look really untidy on the actual forms, how do I get navigation buttons to go through Next, Previous and new for both sub forms?

I tried the below code, this works for the SFrmOrders but not SSFrmBackOrders

The other issue I have is when you click too far an error Debug message appears, I just want a notice to say "no more records avaliable" or simular

Code:
[SFrmNewOrders].SetFocus
RunCommand acCmdRecordsGoToNext
 
A picture of your forms may help with context.
 
Code:
[SFrmOrders]![SSFrmBackOrders].Form.SetFocus
RunCommand acCmdRecordsGoToNext
 
hi mate
thank you for the code, it is showing a run-time error '2449'
invalid method in an expression

Code:
[SFrmOrders]![SSFrmBackOrders].Form.SetFocus
RunCommand acCmdRecordsGoToNext
 
SFrmOrders is in FrmMainDetails?
 
Hi all
I have got a main for with a sub form as shown below named below
FrmMainDetails - Main From
SFrmNewOrders - Sub Form From FrmMainDetails
SSFrmBackOrders - Sub Form From SFrmOrders

What I want is a footer on the main from so I can go through the relevant records and not make it look really untidy on the actual forms, how do I get navigation buttons to go through Next, Previous and new for both sub forms?

I tried the below code, this works for the SFrmOrders but not SSFrmBackOrders

The other issue I have is when you click too far an error Debug message appears, I just want a notice to say "no more records avaliable" or simular

Code:
[SFrmNewOrders].SetFocus
RunCommand acCmdRecordsGoToNext
What is wrong with the Access built in navigation buttons?
 
because I don't want 3 different navigation bars across the bottom, I want my own custom one that tells he user what each one will change
What is wrong with the Access built in navigation buttons?
 
Try:

Me!NameOfSubForm.Form!NameOf2ndSubForm.Form!NameOfCtrl.SetFocus
RunCommand acCmdRecordsGoToNext

Replace NameOfSubForm with the name of your first subform
Replace NameOf2ndSubForm with the name of your second subform
Replace NameOfCtrl with the name of a control (textbox) on your second subform
 
add a code to the subform SSFrmBackOrders:
Code:
Public Sub GoNextRecord()
    On Error Resume Next
    Me.Recordset.MoveNext
    If Err.Number <> 0 Then
        Me.Recordset.Addnew
    End If
End Sub

On the Click event of your command button:
Code:
[SFrmOrders]![SSFrmBackOrders].Form.GoNextRecord
 
Morning
thanks for the below, not too sure what you mean by a control textbox?
Try:

Me!NameOfSubForm.Form!NameOf2ndSubForm.Form!NameOfCtrl.SetFocus
RunCommand acCmdRecordsGoToNext

Replace NameOfSubForm with the name of your first subform
Replace NameOf2ndSubForm with the name of your second subform
Replace NameOfCtrl with the name of a control (textbox) on your second subform
 
Morning
thanks for the below, not too sure what you mean by a control textbox?
The items (Text boxes, List boxes, Lines, Buttons etc) on a form are called controls. I assumed that you would have a text box on the form as these are amongst the most commonly used controls on a form but you could reference any control that can have the focus (so NOT a "line" or "rectangle" for example). In the code that I posted you would need to replace NameOfCtrl with the name of a control on the form which could have the focus. A textbox for example.
 
Hi,
What you have to do is to give the properties of the subform the right values: Record selectors to NO and Navigation buttons to NO. Then create a button on the main form with some code like this: docmd.GoToRecord, me!subFormOfAnyKind.Form,acNext - acPrevious - and so on. The error you can catch it with a procedure on the error code with an If Else-procedure with a message if the error occur. If you want to refresh both subforms you have to multiply the code "docmd. ..." for both of the subforms as on object. And if the subforms are related tables, you don't have to multiply the code for the subforms. It goes automaticaly.

Hopes this helps!
 

Users who are viewing this thread

Back
Top Bottom