473,412 Members | 1,921 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,412 software developers and data experts.

opening corresponding forms or reports

20
I am working in Microsoft Access 2010.

I have a form called "Production Report." There are several input fields on this form, one of which is called "Format."

I also have several other forms, Group2, that correspond to the different values that can be entered in "Format." For example, the "Format" field can be populated with either A, B, C, or D. Based upon which one of these is entered into the "Format" field, what I am trying to do is make it so that the corresponding form is automatically pulled up once the field is populated so that the user doesn't have to take any additional action to open the form from Group2. I would then like the form from Group2 to print on the backside of the "Production Report." I am fairly new to Access, and don't know if this is even possible let alone how to go about doing it.

I also have all of the Group2 forms in the form of reports if that makes anything easier.
I've hit a wall trying to figure this out. Any help would be greatly appreciated!
Jul 17 '19 #1
11 1270
twinnyfo
3,653 Expert Mod 2GB
kledki,

Some thoughts and also a minor caution.

First, What youa re trying to do with opening a Form based upon the value of a control on a form does not sound too terribly difficult. Just use the AfterUpdate Event of the control to openthe Form (btw, I have no idea what you mean by "Group2"):

Expand|Select|Wrap|Line Numbers
  1. Private Sub txtFormat_AfterUpdate()
  2.     Select Case Me.txtFormat
  3.         Case "A"
  4.             Call DoCmd.OpenForm(FormName:="YourFormNameA")
  5.         Case "B"
  6.             Call DoCmd.OpenForm(FormName:="YourFormNameB")
  7.         Case "C"
  8.             Call DoCmd.OpenForm(FormName:="YourFormNameC")
  9.         Case "D"
  10.             Call DoCmd.OpenForm(FormName:="YourFormNameD")
  11.     End Select
  12. End Sub
However, in your case, you may want to add some code to validate that the value entered into your control falls within the parameters of what you need.

Second, typically we don't "print" Forms, as they are merely an interface between the user and the actual data. It is "possible" to print forms, but not in the manner you intend, as it must be printed from within the Operating system and is essentially a "screenshot" of the form (which may be what you want). But, this cannot be done in conjunction with a print job sent from the MS Access engine.

Since you have the "Group2" (still don't know what that means) forms also in the form of reports, there may be some ways to print those reports as sub-reports on the main form, but make them either visible or invisible depending upon the value of your control--this is more involved than what is listed above, butas far as I know, it would not be impossible to do that.

Finally, a minor caution. Because "Format" is a reserved word in MS Access, it is highly recommended that you never use that for the name of a field or control. If you notice above, although I've put the name "Format" in the name of the control, I've "renamed" the control to txtControl.

Other than that, we would need more information before we can provide a better solution.

Hope this hepps.
Jul 17 '19 #2
NeoPa
32,556 Expert Mod 16PB
It seems there's little left to be said. I would only add that terminology is important. Fields are data items within the record of a table or query. Items that can show data on Forms & Reports are Controls. It is also counterproductive to give a Form object a name that includes "Report" in it. That is just asking people to get confused, none more so than yourself.

Otherwise Twinny's said all that needs to be.
Jul 17 '19 #3
kledki
20
Okay, thank you guys. I see now how my terminology may have been confusing and will try to be better about that in the future. By Group2, I simply mean the group that contains forms A, B, C, and D. I have changed the name of the "format" control to "Quality Check" in order to avoid confusion. I attempted to use the code that you provided, but I'm sure I did something wrong because nothing is happening after the control is updated.
Expand|Select|Wrap|Line Numbers
  1. Private Sub Quality_Check_AfterUpdate()
  2. Select Case Me.txtQuality_Check
  3. Call DoCmd.OpenForm(FormName:="SG_Industrial")
  4. Call DoCmd.OpenForm(FormName:="LG_Industrial")
  5. Call DoCmd.OpenForm(FormName:="SG_Retail_Carton")
  6. Call DoCmd.OpenForm(ForrmName:="LG_Retail_Carton")
  7. End Select
  8.  
  9. End Sub
  10.  
Jul 22 '19 #4
twinnyfo
3,653 Expert Mod 2GB
Notice lines 3, 5, 7, 9 in my code example. You have to provide the cases for which these forms will be opened.
Jul 22 '19 #5
kledki
20
Please excuse my ignorance on this, I'm pretty new to coding within Microsoft Access. Here is my cade now but I still cannot get it to work:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Quality_Format_AfterUpdate()
  2. Select Case Me.txtQuality_Format
  3. Case "A"
  4. Call DoCmd.OpenForm(FormName:="SG_Industrial")
  5. Case "B'"
  6. Call DoCmd.OpenForm(FormName:="LG_Industrial")
  7. Case "C"
  8. Call DoCmd.OpenForm(FormName:="SG_Retail_Carton")
  9. Case "D"
  10. Call DoCmd.OpenForm(ForrmName:="LG_Retail_Carton")
  11. End Select
  12.  
  13. End Sub
  14.  
I'm assuming that the cases need to be more specific?
Jul 22 '19 #6
twinnyfo
3,653 Expert Mod 2GB
You need to be more specific and define "still cannot get it to work".

Is there an error? What is the data being stored in the text box? You said you renamed the Control "Qualit Format" but you are referring to it as "txtQuality_Format" in the body of the procedure, but not in the name of the sub. I will tell you that naming a control "txtQualityFormat" is most correct in this situation, but you need to make all references to that control consistent.

One sure way to find out is to insert these two lines at the top of your module:

Expand|Select|Wrap|Line Numbers
  1. Option Explicit
  2. Option Compare Database
You can also make this a default for your VBA:
Tools | Options | Editor Tab | Require Variable Declarion should be checked.
Jul 22 '19 #7
kledki
20
By that I mean that when "QualityFormat" is updated, nothing is happening. The other forms are not opening.
Expand|Select|Wrap|Line Numbers
  1. Private Sub txtQualityFormat_AfterUpdate()
  2. Select Case Me.txtQualityFormat
  3. Case "QualityFormat= SG Industrial"
  4. Call DoCmd.OpenForm(FormName:="SG_Industrial")
  5. Case "QualityFormat= LG Industrial"
  6. Call DoCmd.OpenForm(FormName:="LG_Industrial")
  7. Case "QualityFormat= SG Retail Carton"
  8. Call DoCmd.OpenForm(FormName:="SG_Retail_Carton")
  9. Case "QualityFormat= LG Retail Carton"
  10. Call DoCmd.OpenForm(FormName:="LG_Retail_Carton")
  11. End Select
  12.  
  13. End Sub
Jul 22 '19 #8
twinnyfo
3,653 Expert Mod 2GB
Have you looked at m6y example and have you compared it with what you have? Can you identify any significant differences? You should fix those first.

After you fix those changes, I must ask, are you asking the user to type in the value into txtQualityFormat? If so, this is asking for problems, as this may cause problems when someone mistypes the entry.

In this case, you should create a combo box with a list of values that hte user can select from.

Finally, you should insert a breakpoint in your code at the beginning of the procedure to test if this code is even firing after the text box is being updated. There are a lot of things misaligned with what you have right now, but these things ought to get you headed in the right direction so we can find out why this is not working.
Jul 22 '19 #9
twinnyfo
3,653 Expert Mod 2GB
And, if you create a list box with a list of the Form names, just use the value of the combo box to open the form directly from there:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboQualityFormat_AfterUpdate()
  2.     Call DoCmd.OpenForm(FormName:=Me.cboQualityFormat)
  3. End Sub
Jul 22 '19 #10
kledki
20
Firstly, the ccode example that you provided was invaluable, so thank you. Secondly, I still have a problem. So the "QualityFormat" control is updated after a selection is made from a combo box on the same form called "Resource ID." The code that I have will work properly if "QualityFormat" is typed in manually, but not when it is automatically updated after a selection is made from the combo box. Why is that? Does the code need to be modified to account for the combo box?

Expand|Select|Wrap|Line Numbers
  1. Private Sub QualityFormat_AfterUpdate()
  2.     Select Case Me.QualityFormat
  3.         Case "SG Industrial"
  4.             Call DoCmd.OpenForm(FormName:="SGIndustrial")
  5.         Case "LG Industrial"
  6.             Call DoCmd.OpenForm(FormName:="LGIndustrial")
  7.         Case "SG Retail Carton"
  8.             Call DoCmd.OpenForm(FormName:="SGRetailCarton")
  9.         Case "LG Retail Carton"
  10.             Call DoCmd.OpenForm(FormName:="LGRetailCarton")
  11.     End Select
  12. End Sub
  13.  
P.S.
I referred to the name of the control in question as "Quality Check" once, but that's not correct. The name of the control is "QualityFormat." The names of the forms that I would like to open after "QualityFormat" is updated are SGIndustrial, LGIndustrial, SGRetailCarton, and LGRetailCarton.
Jul 23 '19 #11
twinnyfo
3,653 Expert Mod 2GB
Combo Box:
Name: cboQualityFormat
Row Source Type: Value List
RowSource: "SGIndustrial", "LGIndustrial", "SGRetailCarton", "LGRetailCarton"
Column Count: 1

Expand|Select|Wrap|Line Numbers
  1. Private Sub cboQualityFormat_AfterUpdate()
  2.     Call DoCmd.OpenForm(FormName:=Me.cboQualityFormat)
  3. End Sub
That's all you need.
Jul 23 '19 #12

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

Similar topics

0
by: Nick Rogers | last post by:
After about two months of using Visual Basic . NET 2003 Standard, it suddenly started freezing up whenever it tried to display a Windows form inside a project file. All other files, such as HTML...
5
by: DFS | last post by:
Situation: Access 2003 front-end, containing links to Access 2003, SQL Server 2000, and DB2 tables. None of these tables are local. Hardware: IBM ThinkCentre, 10/100 Ethernet LAN Problem:...
7
by: Steve_Black | last post by:
Hello, I'm toying with the idea of loading a MenuStrip (VB.Net 2005) dynamically based on who is logged into my system. Every user has different security settings and I want to customize the...
2
by: Max | last post by:
I am editting a database created in access 2003 by another programmer. This person has left the company for which the database was created and no documentation. So that I could work on this...
1
by: jdurell | last post by:
I am trying to work with a copy of an access database but I cannot seem to access the forms/reports or code. I am holding shift to go in the back door The queries and tables are there but thats...
3
by: Arne Beruldsen | last post by:
The migration from VB6 is anything but easy. Ok...I have an introductory form (start-up is via sub main) and then several succeeding forms which gather some info. As soon as the info is gathered...
0
by: kkrizl | last post by:
I've tried to research this problem, and I haven't been able to find any references to it. Probably because I shouldn't be doing it, but it was working, and now it's not. I'm trying to develop a...
1
by: kkrizl | last post by:
I've tried to research this problem, and I haven't been able to find any references to it. Probably because I shouldn't be doing it, but it was working, and now it's not. I'm trying to develop a...
1
by: titli | last post by:
Hi All, Please tell me the best solution to implemenet security in access databases , to save the tables, queries, forms , reports as well as the VBA code from user access. The users of the...
2
by: Azanullah | last post by:
warmest greetings and hope all is well, dear sir, Plz help me I have a problem with my Access database I made HR Database in MS Access 2007 and now it's final but when I am opening a form or...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.