473,387 Members | 1,303 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to set focus to a field on subform which is placed on a tab of the mainform

64 64KB
Hi,

I have a

- mainform called: [frm_traject_details]
- a page on the mainform called: [page_status - resultaat]
- a subformelement (for displaying subform) called: [Redenen van winst of verlies]
- a subform called frm_reden

- a combobox on the subform called: cmb_reden_cat

When a certain criteria is not met, i want to show a message and set the focus to a field on the subform.

On the page i have a field in which, in the BeforeUpdate procedure, i have;

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_beforeupdate(Cancel As Integer)
  2. DoCmd.Echo True
  3. Dim ctl As Control
  4.  
  5. If Me![Status Res] <> 5 And Me![Soort traject] < 6 And Me![chk_reden] = False Then
  6. MsgBox ("Het resultaat van dit traject is " & [Status Res].Column(1) & ", geef aan wat de reden(en) hiervoor zijn aub!")
  7. Me.[Redenen van winst of verlies].SetFocus
  8. Me.[frm_redenen].SetFocus
  9. Me.[Redenen van winst of verlies]!cmb_reden_cat.SetFocus
  10. Cancel = True
  11. Exit Sub
  12.  
  13. End If
  14.  
It will generate an error message stating it cannot set focus to [Redenen van winst of verlies]

Any suggestions ?

Thanks,
Pierkes
Aug 26 '14 #1

✓ answered by jforbes

If you are calling the Form_beforeupdate from the main form, I think you want to replace lines 7-9 with:
Expand|Select|Wrap|Line Numbers
  1. Me![Redenen van winst of verlies].Form![cmb_reden_cat].SetFocus
So you would end up with:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_beforeupdate(Cancel As Integer)
  2.  DoCmd.Echo True
  3.  Dim ctl As Control
  4.  
  5.  If Me![Status Res] <> 5 And Me![Soort traject] < 6 And Me![chk_reden] = False Then
  6.  MsgBox ("Het resultaat van dit traject is " & [Status Res].Column(1) & ", geef aan wat de reden(en) hiervoor zijn aub!")
  7.  Me![Redenen van winst of verlies].Form![cmb_reden_cat].SetFocus
  8.  Cancel = True
  9.  Exit Sub
  10.  
  11.  End If
  12.  
Access's syntax can get a little ugly.

2 1235
jimatqsi
1,271 Expert 1GB
Pierkes,
Here is a page a lot of us refer to for help with form/subform references
http://access.mvps.org/access/forms/frm0031.htm

Jim
Aug 26 '14 #2
jforbes
1,107 Expert 1GB
If you are calling the Form_beforeupdate from the main form, I think you want to replace lines 7-9 with:
Expand|Select|Wrap|Line Numbers
  1. Me![Redenen van winst of verlies].Form![cmb_reden_cat].SetFocus
So you would end up with:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_beforeupdate(Cancel As Integer)
  2.  DoCmd.Echo True
  3.  Dim ctl As Control
  4.  
  5.  If Me![Status Res] <> 5 And Me![Soort traject] < 6 And Me![chk_reden] = False Then
  6.  MsgBox ("Het resultaat van dit traject is " & [Status Res].Column(1) & ", geef aan wat de reden(en) hiervoor zijn aub!")
  7.  Me![Redenen van winst of verlies].Form![cmb_reden_cat].SetFocus
  8.  Cancel = True
  9.  Exit Sub
  10.  
  11.  End If
  12.  
Access's syntax can get a little ugly.
Aug 26 '14 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Charlene | last post by:
I have an Invoice/Invoice Details form/subform. In the page footer of the Invoice Details subform I have a textbox with the control source set to =Sum(). I then pull this value into the main form...
1
by: MLH | last post by:
I have frmVehicleEntryForm and on it is frmAddnlOwnrListSubForm. The subform is unbound and lists records in a table, allowing the user to change values in CheckMark controls on the subform as...
1
by: tizmagik | last post by:
I have a Starting form ("frmStart") and a main form ("frmCustomer") inside frmCustomer are two subform, one with it's own subform. So frmCustomer has two subforms ("sbfArtist" and "sbfAddress")...
18
by: Robert Jacobs | last post by:
Please advise... I currently have a Mainform (Customers) and a Subform (Service Requests) with a one to many relationship (one customer, many service requests) with a CustomerID that is unique...
1
by: Rosy | last post by:
I have a form "A" that is set on table vessel names. I have subform "B" that is set on table vessel info. I want form "B" to update based on what vessel I choose in form "A". I know this is...
3
by: gblack301 | last post by:
Hi All, I have been racking my brain for sometime in trying to resolve this and now I am just wiped out. MS-Access 2003 I have a main form that contains several selection options (combo...
7
by: JohnHo | last post by:
I have been working with Access for a little while but have never used mainforms/subforms before. Here is my problem/scenario: I have a main form (frmMain) with a few other forms for data data...
3
Sigma7
by: Sigma7 | last post by:
This is my issue- I am a true novice to DBMS. I would like to accomplish the following feat: I have created a mainform and subform, and I would like to have the users to input information into the...
0
by: MissE | last post by:
Hello Afternoon! I've been trying to work out whats going wrong with my function for the last 2 days. I give up... I have a main form (Infinity) with a command button which pops up a subform...
10
by: freedemi | last post by:
I have a mainform (frm_main) with a subform (frm_pyrovola) (linked with "id", with relationship 1-many). In subform, i have a combobox field where it takes data from table/query with the code bellow...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.