Reset text box to zero

R

Richard

Hi

How can I reset this texbox For L = 1 To Me!TextBoxCopies back to
"nothing" after the report has printed. I tried setting the default value to
nothing and 0 but neither had a good results.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Private Sub Label30_Click()
Dim strWhere As String
Dim L As Long

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[LabelID] = " & Me.[LabelID] 'This code prints a report
to default printer

For L = 1 To Me!TextBoxCopies
DoCmd.OpenReport "rptLabel", acViewNormal, , strWhere
Next L
DoCmd.GoToRecord , , acNewRec
End If
End Sub


Thanks
Richard
 
M

MikeJohnB

Try the following

Private Sub Label30_Click()
Dim strWhere As String
Dim L As Long

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[LabelID] = " & Me.[LabelID] 'This code prints a report
to default printer

For L = 1 To Me!TextBoxCopies
DoCmd.OpenReport "rptLabel", acViewNormal, , strWhere
Next L
DoCmd.GoToRecord , , acNewRec
End If
Me!TextBoxCopies = "" 'Set Back to Nothing before End Sub
End Sub


Does this help????

Kindest Regards
Mike B
 
R

Richard

Thanks that's what I was looking for..


MikeJohnB said:
Try the following

Private Sub Label30_Click()
Dim strWhere As String
Dim L As Long

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[LabelID] = " & Me.[LabelID] 'This code prints a report
to default printer

For L = 1 To Me!TextBoxCopies
DoCmd.OpenReport "rptLabel", acViewNormal, , strWhere
Next L
DoCmd.GoToRecord , , acNewRec
End If
Me!TextBoxCopies = "" 'Set Back to Nothing before End Sub
End Sub


Does this help????

Kindest Regards
Mike B
--
Advice to Posters.
Check your post for replies or request for more information.
Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B


Richard said:
Hi

How can I reset this texbox For L = 1 To Me!TextBoxCopies back to
"nothing" after the report has printed. I tried setting the default value to
nothing and 0 but neither had a good results.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Private Sub Label30_Click()
Dim strWhere As String
Dim L As Long

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"
Else
strWhere = "[LabelID] = " & Me.[LabelID] 'This code prints a report
to default printer

For L = 1 To Me!TextBoxCopies
DoCmd.OpenReport "rptLabel", acViewNormal, , strWhere
Next L
DoCmd.GoToRecord , , acNewRec
End If
End Sub


Thanks
Richard
 
L

Linq Adams via AccessMonster.com

To be honest, I'm having a little problem following exactly waht you're doing
here, but in your code

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

If Me.NewRecord Then 'Check there is a record to print
MsgBox "Select a record to print"

the line

MsgBox "Select a record to print"

will never execute. By saving the record with

If Me.Dirty Then 'Save any edits.
Me.Dirty = False
End If

you've changed the record's staus and it is no longer a New Record.

Just thought you should know.
 
M

MikeJohnB

Hey Linq, well done, I missed that totally, my only excuse, it wasn't the
question posed :(

Kindest Regards

Mike B
 
R

Richard

Ling,

Here is the link to Allen Browne's web page.

http://allenbrowne.com/casu-15.html

I have been using this code for over a year now in different apps. so if it
doesn't work it news to me... It just saves and prints the record in the
form, and if theres no record the you get the message " Select a record to
print " works great and as far as the added line by john ...flawless so far
:)

Thanks
Richard
 
M

MikeJohnB

Ahhhhh, I see what Alen is doing I think

Consider if you have the database open with a new record which has no data
in it yet????

The dirty command wont fire because it is not dirty, you have not clicked in
any controls and entered data.

The next line of code then applies, the Me.NewRecord is now true so a
message box will infact fire up asking you to "Check there is a record to
print"

I think that clears up the mystery??????

Kindest regards

Mike B
 
R

Richard

Mike,

Maybe Allen Browne will chime in on this one and explain how his code works...
It's really no mystery to me, like I said its been serving me well with zero
errors for over a year now! And to be honest I love this code for my Dymo
labels Apps.

http://allenbrowne.com/casu-15.html


Thanks
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top