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

Access VBA Help! Show the Label Report Based on ID in Current Form

I am having hard time finding the way to make the database below.

I have:
-Form "frmInvoice" with subform "Allocation" based on table "tblInvoice" and "tblAllocation". "invID" is auto number in tblInvoice and joins main form "frmInvoice" and subform "Allocation".

-Label report "Labels qryLabels," based on a query qryLabels. qryLabels is based on tblInvoice and tblAllocation. label report "Labels qryLabels" has "invID" field.


In form "frmInvoice," there is a command button "Command260", and when a user clicks this button, only label report that has same invID as the current form shows up.

I tried the following code and didnt work.


Expand|Select|Wrap|Line Numbers
  1. On Error GoTo Err_Command260_Click
  2.  
  3.     Dim stDocName As String
  4.     Dim strgetinvID As String
  5.  
  6.     strgetinvID = Me.invID
  7.    ' (I also tried "=Me.invID.Value)
  8.  
  9.     stDocName = "Labels qryLabels"
  10.     DoCmd.OpenReport stDocName, acViewPreview, , invID = strgetinvID
  11.  
  12. Exit_Command260_Click:
  13.     Exit Sub
  14.  
  15. Err_Command260_Click:
  16.     MsgBox Err.Description
  17.     Resume Exit_Command260_Click
  18.  
  19. End Sub
I appreciate any help.
Oct 24 '07 #1
3 2179
Jim Doherty
897 Expert 512MB
I am having hard time finding the way to make the database below.

I have:
-Form "frmInvoice" with subform "Allocation" based on table "tblInvoice" and "tblAllocation". "invID" is auto number in tblInvoice and joins main form "frmInvoice" and subform "Allocation".

-Label report "Labels qryLabels," based on a query qryLabels. qryLabels is based on tblInvoice and tblAllocation. label report "Labels qryLabels" has "invID" field.


In form "frmInvoice," there is a command button "Command260", and when a user clicks this button, only label report that has same invID as the current form shows up.

I tried the following code and didnt work.


Expand|Select|Wrap|Line Numbers
  1. On Error GoTo Err_Command260_Click
  2.  
  3. Dim stDocName As String
  4. Dim strgetinvID As String
  5.  
  6. strgetinvID = Me.invID
  7. ' (I also tried "=Me.invID.Value)
  8.  
  9. stDocName = "Labels qryLabels"
  10. DoCmd.OpenReport stDocName, acViewPreview, , invID = strgetinvID
  11.  
  12. Exit_Command260_Click:
  13. Exit Sub
  14.  
  15. Err_Command260_Click:
  16. MsgBox Err.Description
  17. Resume Exit_Command260_Click
  18.  
  19. End Sub
I appreciate any help.

the where clause argument of the OpenReport is not satisfied in that you have not passed it correctly, compare yours to the below
I can see that you have declared (Dim) strgetinvID as String but so that you know the difference

if your invID were a numeric value then the below would satisfy

DoCmd.OpenReport stDocName, acViewPreview, , "invID =" & strgetinvID

Your invID is a declared text based string so the below satisfies

DoCmd.OpenReport stDocName, acViewPreview, , "invID ='" & strgetinvID &"'"

As an aside to this research for your benefit the difference between the BANG and DOT operators please in how you reference controls in Access

Jim :)
Oct 24 '07 #2
the where clause argument of the OpenReport is not satisfied in that you have not passed it correctly, compare yours to the below
I can see that you have declared (Dim) strgetinvID as String but so that you know the difference

if your invID were a numeric value then the below would satisfy

DoCmd.OpenReport stDocName, acViewPreview, , "invID =" & strgetinvID

Your invID is a declared text based string so the below satisfies

DoCmd.OpenReport stDocName, acViewPreview, , "invID ='" & strgetinvID &"'"

As an aside to this research for your benefit the difference between the BANG and DOT operators please in how you reference controls in Access

Jim :)


Duh! I feel so stupid. I was trying just to make this work for 3 hours! Thank you very much for your quick response & help, your advice taught me something today :-) Have a nice evening!
Oct 24 '07 #3
Jim Doherty
897 Expert 512MB
Duh! I feel so stupid. I was trying just to make this work for 3 hours! Thank you very much for your quick response & help, your advice taught me something today :-) Have a nice evening!
Haha don't feel bad about it we all make mistakes :)

You're very welcome

Jim :)
Oct 24 '07 #4

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

Similar topics

28
by: Neil Ginsberg | last post by:
I have a client who is using Access 2002/2000 (the database itself is written in 2000), and is considering migrating to Access 2003. Any recommendations on whether Access 2003 is worth the migrate,...
0
by: htmlgeek | last post by:
I've beaten my head againts this for two weeks and would appreciate any help. Am running Dreamweaver 2004 MX asp pages with MS Access 2000 and then 2003 and received same problems! I've rebuilt...
3
by: Marc Nadeau | last post by:
Hi, I have a new project that consist of transfering a JD Edwards Database to an MS Access database. I am just starting to learn how those 2 databases works. What is the general idea behind...
2
by: J | last post by:
I use Access 97 and Windows XP (Sp2 if that matters) I mostly program for myself, but am now writing an application for my wife's club and need to include a help file with the database I am...
1
by: Tim Hunter | last post by:
Hi, I am using Access 2003 with WinXP/sp#2. I have built a Help file using MS HTML Help Workshop that includes a TOC as well as an Index file. My problem is how do I call this from Access. I do...
70
by: Neil Ginsberg | last post by:
Does anyone know if a new version of Access is due to come out anytime soon? Thanks, Neil
57
by: TC | last post by:
I'd like to open a discussion about the state of the industry. For the past year, I've been unable to find competent Access developers available for hire. I'm worried about that. I think there's...
21
by: Bigpond News | last post by:
Work at a large site - 1000+ PC's. Mixture of Win98 & WinXP. Majority of applications using Access 97. If I compile the Acc97 application on a Win98 PC, the .mde will run perfectly on both...
18
by: surfrat_ | last post by:
Hi, I am having the following problems in getting Microsoft Visual Studio 2005 Professional to link to an Access .mdb database. Please help me to sort this out. Problem 1: The Microsoft...
11
by: Chad | last post by:
Hi Is it possible to substitute an alternative data source (eg MySQL or SQL Server) into an existing MS-Access application?
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.