473,779 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Unbound Master with bound detail subform based on a query

5 New Member
I am trying do display some data in a continous subform which is part of an unbound form.

The master form is supposed to display a error discription window. To do this I call the following sub procedure
Expand|Select|Wrap|Line Numbers
  1.  
  2. Public Sub display_error_payadvice( LegacyEmpNumber As String, FullName As String, EmployeeNumber As String )
  3.  
  4.    DoCmd.OpenForm "ErrorPayAdvice"
  5.    Forms!ErrorPayAdvice.[employee Number] = EmployeeNumber
  6.    Forms!ErrorPayAdvice.[Full Name] = FullName
  7.    Forms!ErrorPayAdvice.[Legacy Employee Number] = LegacyEmpNumber
  8.    DoCmd.OpenForm "ErrorPayAdvice"
  9.  
  10.  
The 2 continous sub forms are based on the following queries

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT PAY_RUN_RESULTS.ELEMENT_NAME, Sum(PAY_RUN_RESULTS.AMOUNT) AS AMOUNT
  3. FROM PAY_RUN_RESULTS
  4. GROUP BY PAY_RUN_RESULTS.ELEMENT_NAME, PAY_RUN_RESULTS.PAY_ADVICE, PAY_RUN_RESULTS.EMPLOYEE_NUMBER
  5. HAVING (((PAY_RUN_RESULTS.PAY_ADVICE)='D') And ((PAY_RUN_RESULTS.EMPLOYEE_NUMBER)=Forms!ErrorPayAdvice![Employee Number]));
  6.  
  7.  
The Master form displays the employee number, name details and legacy employee number Ok but the subforms do not. If I open the subforms separately, after entering a value for the employee number parameter, the forms display the correct data. If I right click into the subform rectangle on the screen and select the 'Remove Filter/Sort' the data then appears. I have looked through the properties for the subform but I cannot find a Filter/Sort property. What do I need to do in order to get the subforms to work?

The version of Access I am using is 2003 on Windows XP.
Apr 11 '08 #1
5 2822
nspader
78 New Member
I am very confused as to what you are doing or trying to do.

Also, what you are trying to display.

Maybe it is just me, but I could use some more specific explanations.

Nick
Apr 11 '08 #2
vegeta456
5 New Member
Ok.
What should happen is that the sub procedure
sets some text items on on the form 'ErrorPayAdvice '

The form is then opened and the and the records in the subform displayed. The subform is based on the query shown and returns rows related to the the employee number in the master form.
Apr 12 '08 #3
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Hi. I suspect that you are running into difficulties because at the time the form/subform combination is opened the unbound field Employee Number has no value set, so the underlying query you list returns no records. You should be aware that the sequence of events that occur when a form opens means that the recordsource for the subforms (the query you list) will be evaluated before your sub display_error_p ayadvice updates the fields which are supposed to filter the subforms.

Your second call to the OpenForm method in line 7 will not help you here, as the form is already open from the call in line 3. The second call is simply redundant.

To resolve this you will need to requery each subform after you set the field values in the main form within your subroutine. This refreshes the recordset which should now filter according to the employee number that is now present in the form.
Expand|Select|Wrap|Line Numbers
  1. Forms!ErrorPayAdvice.[employee Number] = EmployeeNumber
  2. ...
  3. Forms![First Subform Name].Form.Requery 
  4. Forms![Second Subform Name].Form.Requery
  5.  
You will need to substitute the actual names of your subforms in the form field references for the requery calls above.

There are other ways to tackle this (by setting the recordsource for each subform to an SQL statement built in your code, for instance) but the requery method should at least resolve why you cannot see any records at present.

-Stewart
Apr 13 '08 #4
vegeta456
5 New Member
Thanks Stewart for your reply

Tried your suggestion but I am getting a Run time Error 2450

'Microsoft Office Access Cannont find the form 'Pay Run Earnings New' (this is one of the subforms) I think this is because the subform is not open at the time because I got the same error when I tried setting the values of the text items in the main form before the 'DoCmd.Openform
Apr 14 '08 #5
Stewart Ross
2,545 Recognized Expert Moderator Specialist
Thanks Stewart for your reply

Tried your suggestion but I am getting a Run time Error 2450

'Microsoft Office Access Cannont find the form 'Pay Run Earnings New' (this is one of the subforms) I think this is because the subform is not open at the time because I got the same error when I tried setting the values of the text items in the main form before the 'DoCmd.Openform
Apologies, I missed out the form name from the skeletons:

Expand|Select|Wrap|Line Numbers
  1. Forms![ErrorPayAdvice]![Pay Run Earnings New].Form.Requery
  2. Forms![ErrorPayAdvice]![Second subform name].Form.Requery
-Stewart
Apr 14 '08 #6

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

Similar topics

2
2357
by: Alex | last post by:
Subject: Looking for an XML (database-based) Query Reporting Tool/advice First off, let me apologize if this thread is somewhat off topic... PLEASE REPLY TO: xml@solex-bi.com I am looking for a way to query XML documents stored in an Oracle 9i database, contained in an unstructured CLOB column, much like one would with a traditional BI query reporting tool, but using XPath or XQuery
2
1288
by: istorehere | last post by:
Hi there, I have created a subform with query. but it doesnt allows me to add/edit records. i have two tables. Items : Item_code,ItemDesc,Reference Order : Orderno,Item_code,Qty
2
1842
by: mnms | last post by:
Hi, I'm trying to create an "overview" form. And I haven't been able to figure out how to get Access to do what I want yet. Basicly what I want, is to populate a subform based on a field selection. In other words, I have several fields like colour, shape, location etc. on my Main form. Now I want to add a subform to my unbound mainform, showing what I have in a table, depending on what is selected in the fields. So if I choose red,...
8
5176
by: NJonge01 | last post by:
Great thanks to all the helpful responses I've read! Recently using MS Access after a lengthy (7-10 years) away from the tool. I apologize for posting a question that for all intents & purposes appears to have been answered several times. Unfortunately, I've tried nearly a dozen approaches that seem to work for others on this board with similar (nearly identical in some cases) problems. I would like to navigate through records on a subform...
13
4702
by: shreyansghia | last post by:
Hello , I am using MS Access 2007. Now if i ve a subform based on a table, filtering the subform is extremely easy . I only ve to click the relevant column head on the subform and check/uncheck the required records (clicking on the column head would yeild a drop down list). However , since my subform is based on a query , i cannot avail the filter option using the above method. I get the error no 3075. Can somebody please help me...
1
1617
by: MikeMikerson | last post by:
Hello, I am need to create a subform (no problem) of a form based query (a problem). I need a form that will prompt the user to enter in a name, and the form will then display a query of the persons transactions. The ideal situation would be that the executed query would remain as part of the record because there will be many of these "searches" stored within this form. I have:
1
2676
by: daleshei | last post by:
I have a combo box with list all the queries I have on my database: Form is called: frm_qry_slct Combo box (Unbound): Combo23 RowSourceType: Table/Query RowSoource:SELECT FROM MSysObjects WHERE =5 And Like "qry_#*" ORDER BY ; Then my SubForm
2
2723
by: csolomon | last post by:
Happy Hump Day! I was wondering if it would be possible to some how resize my subform based on the number of records it holds. I have a subform that I populate via a non-updatable query. It just shows the user what he/she has ordered. Based on this information, I would like for the user to just be able to view the information with out having to scroll. can this be done? Thanks
12
5062
by: kashif73 | last post by:
Hi, I have a subform (datasheet view) on my Mainform, where a user can enter information. I need help on how to display the required number of rows in my subform based on the number selected in the dropdown box on my mainform. Please see the attached GIF. for example if a user selects 5 from the dropdown then automatcially the subform below should display 5 rows for entering data, with a default value of "UNKNOWN" in each column. many...
0
9471
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10302
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10136
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10071
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9925
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6723
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5372
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5501
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3631
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.