Buttons on footer to choose next / Previous Records on - SFrm (1 Viewer)

stu_c

Registered User.
Local time
Today, 19:02
Joined
Sep 20, 2007
Messages
489
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
 

jdraw

Super Moderator
Staff member
Local time
Today, 14:02
Joined
Jan 23, 2006
Messages
15,379
A picture of your forms may help with context.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:02
Joined
May 7, 2009
Messages
19,237
Code:
[SFrmOrders]![SSFrmBackOrders].Form.SetFocus
RunCommand acCmdRecordsGoToNext
 

stu_c

Registered User.
Local time
Today, 19:02
Joined
Sep 20, 2007
Messages
489
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:02
Joined
May 7, 2009
Messages
19,237
SFrmOrders is in FrmMainDetails?
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:02
Joined
Sep 21, 2011
Messages
14,273
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?
 

stu_c

Registered User.
Local time
Today, 19:02
Joined
Sep 20, 2007
Messages
489
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?
 

bob fitz

AWF VIP
Local time
Today, 19:02
Joined
May 23, 2011
Messages
4,721
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
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:02
Joined
May 7, 2009
Messages
19,237
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
 

stu_c

Registered User.
Local time
Today, 19:02
Joined
Sep 20, 2007
Messages
489
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
 

bob fitz

AWF VIP
Local time
Today, 19:02
Joined
May 23, 2011
Messages
4,721
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.
 

so10070

Registered User.
Local time
Today, 20:02
Joined
Aug 18, 2016
Messages
51
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

Top Bottom