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

Automate Print Labels After Set Number of Table Entries

19
Hello,

I’d like to make an inquiry into how to best perform a task in access 2003. I have a form which enters data into a table. This in turn is linked to a label. After ten data entries into the table, I’d like a label to print. Is it best for me to use a counter on the ‘save’ button in my form or is there an easier way to do this? I’d also like to be able to print a partial label say 3, 5 or 7 enters through my process, I’m thinking maybe a second ‘instant pint’ button on the form would cover this however if I tie the ‘save’ button to a 10 count, will it over complicate my code. I’m a beginner so I’d really like to keep it simple. Any words from wiser people would be appreciated.

Thanks,
Peader
Oct 17 '07 #1
13 1616
nico5038
3,080 Expert 2GB
Best probably to add a "Printed" YesNo field.
When a row has been entered a query counting the records with PrintedYN = False will give the newly entered rows. When greater or equal 10 run the labelprint and issue an update query to set the PrintedYN field to True.

For the counting you can use the DCount() function.

Getting the idea ?

Nic;o)
Oct 17 '07 #2
Peader
19
thanks for pointing me in right direction nico5038, it's taken me a while however i'm beginning to make progress
Oct 22 '07 #3
nico5038
3,080 Expert 2GB
Don't hesitate to post when stuck. I'm here to help.
I start always with "pointers" as I know how much satisfaction it gives when you do a job (almost) by yourself.

Nic;o)
Oct 22 '07 #4
Peader
19
Thanks Nico
I've prepared the table, macro and query's however I'm now having trouble running a IF statement to check the printed files, any idea's on where I'm going wrong?
Expand|Select|Wrap|Line Numbers
  1.     IF (dcount(printed, '10pkBoxLabels ',[printed = false] >10 then
  2. 'I've set up a macro to print the label
  3.     stDocName = "Open10pkLabelMacro"
  4. 'then another query to update the printed fields
  5.     stDocName = "UpdatePrintedQuery"
  6.     End IF
  7.  
I have it set up to run on a command button execution.

Thanks,
Peader
Oct 27 '07 #5
nico5038
3,080 Expert 2GB
Hmm, your Dcount is terribly mutilated, try:

Expand|Select|Wrap|Line Numbers
  1. IF (dcount('printed', '10pkBoxLabels','[printed] = false') >10) then
  2.  
Please pay more attention to the syntax and how to use () and [].
The Access helpfile (F1) gives some pritty good descriptions.

Nic;o)
Oct 27 '07 #6
Peader
19
I corrected the Dcount statement to:

If (DCount("[printed]", "10pkBoxLabels", "[printed] = False") > 10) Then
stDocName = "Open10pkLabelMacro"
stDocName = "UpdatePrintedQuery"
End If

However it still doesn't work. Regardless of the number of printed true's/false's it does not run the macro or update the table, no warnings, appears nothing is happening . Could it be related to the fact that prior to running the If statement i already run an update query to modify the source table?

I'm guessing the previous query shouldn't matter. The IF statement looks pretty simple. I'm trying to 'kis' (helps me understand whats happen, no point getting carried away with myself on my first database :) )
Oct 27 '07 #7
nico5038
3,080 Expert 2GB
When your previous update does change the [printed], then it's obvious not triggering this IF statement.
Just place a breakpoint (click in left "ruler" to get a round dot) and start the code from the form by pressing the button.
The code will halt on the breakpoint and now press F8 for single line execution to see what happens.

Nic;o)
Oct 27 '07 #8
Peader
19
Nico thanks for the advise so far it's been very helpful.

No joy when i inserted the break point and used F8 to skip down the line in the code however it didn't seam to have an effect.

I've created the Dcount function in a query to check it's correct, it worked fine.

I then removed the IF statement and left the macro, my thinking was the macro should have run however it didn't.

Here's the preceding code:
'go to last record, this line is probably not needed however my code works with it, so i left it in
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.GoToRecord , , acLast
'insert new record
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.GoToRecord , , acNewRec
'I run an update query to pair up details from a external excel file with the item selected in the form, i turn off then on warnings so the user doesn't have to repeatedly check ok
Expand|Select|Wrap|Line Numbers
  1.     DoCmd.SetWarnings False
  2.     stDocName = "10pcksStickerDescription"
  3.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  4.     DoCmd.SetWarnings True
'i had ' out the IF statement to check if the macro ran here, however it didn't
Expand|Select|Wrap|Line Numbers
  1.     'If (DCount("printed", "10pkBoxLabels", "printed = False") > 10) Then
  2.     stDocName = "Open10pkLabelMacro"
  3.     'stDocName = "UpdatePrintedQuery"
  4.     'End If
I then moved the IF portion to run after an update, still no joy.
I then removed the update query that matches the external data, however it still appears the IF statement does not run.

I'm really lost here as to why something that appears to be correct is not getting picked up when the code is ran?

Any advise or explanation of whats happening would be very much appreciated.
Oct 28 '07 #9
nico5038
3,080 Expert 2GB
When the code isn't executed, then you're using the wrong event.
What event did you use for your code ?

Nic;o)
Oct 28 '07 #10
Peader
19
Hello Nico

I use the On Click event to run. I also tried the after update event specifically for the IF statement alone however this didn't work!?!?

Thanks,
Peader
Oct 28 '07 #11
nico5038
3,080 Expert 2GB
When in the OnClick event of a button, the code should execute.
Make sure the breakpoint is set within the eventcode and try again.

Nic;o)
Oct 28 '07 #12
Peader
19
Oh yes, a thing of amazement, it's working. :)

Nic;o) thanks for the advise and direction. You've really gone out of your way to be more than helpful.

Here's the final IF Statement code for anybody reading this thread in the future.

Expand|Select|Wrap|Line Numbers
  1.     If (DCount("printed", "10pkBoxLabels", "printed = False") > 10) Then
  2.     stDocName = "Open10pkLabelMacro"
  3.     DoCmd.RunMacro stDocName
  4.     DoCmd.SetWarnings False
  5.     stDocName = "UpdatePrintedQuery"
  6.     DoCmd.OpenQuery stDocName, acNormal, acEdit
  7.     DoCmd.SetWarnings True
  8.     End If
My problems were simply lack of experience related. While i might not have though it at times over the last couple of weeks, access really is a beautiful thing :P
Oct 28 '07 #13
nico5038
3,080 Expert 2GB
Glad it's working for you now :-)

Success with your application !

Nic;o)
Oct 28 '07 #14

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

Similar topics

7
by: Shyguy | last post by:
I have an option group with about 30 options. I would like to have the Option Labels get their text from a table. Is this possible, and if so how? Also, is it possible to embad a font into a...
2
by: Fred | last post by:
Hi. Sorry, but I don't know where else to ask. I wrote a access shipping database and we currently use the web interface for DHL to print shipping labels. That means we have to manualy transpose...
2
by: ghadley_00 | last post by:
Hi, Is there a way to have the labels in a MS access database switchboard dynamically generated based on values in a table? I have a table of items (let's call it table Main) , each of which is...
9
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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:
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
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...

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.