MSAccess Form VBA saving

Good morning,
I have a problem this morning...
I have a form in which I can enter up to 50 numbers and when I click on print, it will print my report as I want to.  This work great.  The problem is :  is there a way that the 50 numbers I have entered will be memorise (saved) when I finished printing, for the next time I will need to print the report.  I want to be able to change some number, erase some and keep some.........................

Can you Expert help me please.  Thanks
form.jpg
code-vba.jpg
Nancy TherrienTI Tech and NetworkAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ste5anSenior DeveloperCommented:
It's Access.. Store those numbers in a table?!
Nancy TherrienTI Tech and NetworkAuthor Commented:
Hello Ste5an,


I have tought a creating a table for that but I don't know how to process from VBA................
ste5anSenior DeveloperCommented:
Create a table first. then bind the form to that table. use an continuous form. Then you don't need so much controls.
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Jeffrey CoachmanMIS LiasonCommented:
I would ask why those number were not stored in a table all along.
(in the same table that stores the other form fields)
This would help if:
You need a history of those numbers
You need to see when they were entered? (set a default value of Today's date and time)

So can you could tell us why these numbers are being entered into an "unbound" control?

Just curious...

JeffCoachman
Nancy TherrienTI Tech and NetworkAuthor Commented:
Hello Jeffrey,  Each month we have a list of job order in a excel form that we need to type in that form for it to give us the report we want.  We were not keeping it cause we did'nt need it until now.

Now I have to keep it and be able to delete and modify it on request and print the same report.

I have create a table to put them in but I have to figure out how to link it to my form......

Thanks
PatHartmanCommented:
Your original design was unnormalized.  Because it was flat like a spreadsheet, and had data that repeated in columns rather than rows, you needed to decide at design time the maximum you would allow.  Now that you have your data in rows (one row per job), you can technically support an infinite number of jobs and no change would be required if all of a sudden you needed to report on 100 jobs.  That is the beauty of normalization.  Rows are free, columns are expensive.

You need to import the data from the spreadsheet or link to the spreadsheet.  I prefer linking since this isn't something that you actually need to keep.  Each time you run the reports, you will be using a new version of the list.  The code you have  loops through the controls on the form.  The new code will open a recordset and loop through the rows in the recordset.
Dim db as DAO.Database
Dim rs as DAO.Recordset
Dim td as DAO.Tabledef

Set db = CurrentDB()
Set td = db.Tabledefs!yourtablname
Set rs = td.OpenRecordset

Do Until rs.EOF = True
  .... your print report code
    rs.MoveNext
Loop

Open in new window

Nancy TherrienTI Tech and NetworkAuthor Commented:
Hello all,
Thanks for all your answer.  I have create my table and yes it is a better idea.  Thanks
Mr PatHartman I will try your code for my report.  

Thanks again
Nancy TherrienTI Tech and NetworkAuthor Commented:
Hello,  It is giving me a non definite something error.........
Is the way I have the date to be a filter will work ?

thanks
Nancy TherrienTI Tech and NetworkAuthor Commented:
Ok I have figure out the non definite error , the DAO was not include.

Now it seems to print something but very too much.

Private Sub cmdPrint_Click()

       
Dim sfilter As String
Dim stDocName As String
           
                 
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim td As DAO.Tabledef

Set db = CurrentDb()
Set td = db.Tabledefs!tbl_NoJobRequis
Set rs = td.OpenRecordset

Do Until rs.EOF = True
         
 'sfilter = "[NO_JOB]=" & ctl & " AND [DATE]>=#" & Format(DateValue(Me.txtDate), "yyyy\/mm\/dd") & "#"             this seems not to work, giving a error

           sfilter = "[DATE]>=#" & Format(DateValue(Me.txtDate), "yyyy\/mm\/dd") & "#"
            stDocName = "rpt_Temps Job Particulier sans critere"
            DoCmd.OpenReport stDocName, , , sfilter           'not working cause printing a way too much pages.........
    rs.MoveNext
Loop

         
 '   DoCmd.Close
 '   DoCmd.OpenForm "menu"
End Sub
PatHartmanCommented:
You need to include the Job criteria also.  Use the Where argument rather than the filter.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Nancy TherrienTI Tech and NetworkAuthor Commented:
Hello PatHartman,

Thanks you for your help.  It is working great now.

Here is my code :
Private Sub cmdPrint_Click()

       
Dim sfilter As String
Dim stDocName As String
Dim No_Job As String
           
           
                 
       
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim td As DAO.Tabledef

Set db = CurrentDb()
Set td = db.Tabledefs!tbl_NoJobRequis
Set rs = td.OpenRecordset

Do Until rs.EOF = True
           With rs
            No_Job = !No_Job
            sfilter = "[No_Job]=" & !No_Job & " AND [DATE]>=#" & Format(DateValue(Me.txtDate), "yyyy\/mm\/dd") & "#"
            stDocName = "rpt_Temps Job Particulier sans critere"
            DoCmd.OpenReport stDocName, acViewNormal, , sfilter
           End With
    rs.MoveNext
Loop

         
 '   DoCmd.Close
 '   DoCmd.OpenForm "menu"
End Sub
Nancy TherrienTI Tech and NetworkAuthor Commented:
thanks very much
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.