Get to print on specific record after requery

K

Ken Ivins

Hi folks,

I have a form with a subform. The subform is in a single record view but can
contain multiple records. I want to print a report of only the one record I
am on in the subform. The first step is the convert the numbers into words
(I have this code in a module) and then save this data in my table. Then I
save it and then requery (see code below). Unfortunately this resets the
records back to the first record in the sub form and prints the report with
just the first record.

Now I could have a separate table that I delete all records and then append
it with the new data (this would preclude storing the numbers into words
data) but was wondering if there might be a better way to navigate back the
record I want. I tried book marking but it did not work (maybe I did it
wrong).

Any other ideas?




Dim stDocName As String
Dim WordDollars As String

WordDollars = ConvertCurrencyToEnglish(Me!AmountinNumbers)

Me.DollarsInWords = WordDollars
Me!PayableAddress1.SetFocus
DoCmd.Save
DoCmd.Requery

stDocName = "rptPrintOneCheck"
DoCmd.OpenReport stDocName, acPreview, , "CheckID = " & Me.CheckID & ""
 
A

Albert D.Kallal

Why do you do a requery here?

And, that 'save' command actually saves the form, not your data!!!

Try the follwing:
Dim stDocName As String
Dim WordDollars As String

WordDollars = ConvertCurrencyToEnglish(Me!AmountinNumbers)

Me.DollarsInWords = WordDollars
Me!PayableAddress1.SetFocus
me.refresh

stDocName = "rptPrintOneCheck"
DoCmd.OpenReport stDocName, acPreview, , "CheckID = " & Me.CheckID & ""

I assume this code is being run from the sub-form...right?
 
K

Ken Ivins

Dear Albert,

Thanks, that worked. The code was run for the subform so it was fine.
Requery and Refresh gets me confused. Sometimes one works how I think it
should and sometimes not. Some day I'll notice the pattern and figure out
why.

Thanks for the Save tip. I thought it saved the record. Now I know better.
I'm learning all the time.

I appreciate your assistance and time,
Ken Ivins
 

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