Solved

How do I make a form save the data entered by user in the form?

Posted on 2011-03-01
3
217 Views
Last Modified: 2012-05-11
Hi,

I have a dialogue box with 4 combo boxes that allow the user to enter dates.

these dates are then used to update a table in the database to be used in several queries.

The update works fine but my only issue is once the user as finished that step of updating the dialogue box they move on to other steps. But if a user thinks, 'hang on did I really enter the correct dates?" I want them to be able to go back to the form .... (A command button opens the form)...and on opening it I want the user to see the dates they have entered in the session without necessarily digging through the database for the table that has been updated?

i'm pretty sure thi is a simple task.

I've attached the code i am using for the dialogue box. Is there something i need to code for the form itself hat holds the dialogue box?


Option Compare Database

Private Sub CmdCancel_Click()

DoCmd.Close acForm, "Update_Valdate"

...........................................................
End Sub

Private Sub CmdOK_Click()

DoCmd.SetWarnings False


If IsNull(cbovaldate) Or IsNull(cboNZRG0date) Or IsNull(cboNBDate) Or IsNull(cboBOYStart) Then
    MsgBox "Valuation dates may not be blank!", vbExclamation + vbOKOnly
    Exit Sub
    End If

   

DoCmd.RunSQL "Update zzvaldate set zzvaldate.Valuation_Date = #" & Forms!Update_Valdate!cbovaldate & "# ; "

DoCmd.RunSQL "Update zzvaldate set zzvaldate.Valuation_Date_yyyymmdd = " & Forms!Update_Valdate!cboNZRG0date & " ; "

DoCmd.RunSQL "Update zzvaldate set zzvaldate.NB_start_date =# " & Forms!Update_Valdate!cboNBDate & " #; "

DoCmd.RunSQL "Update zzvaldate set zzvaldate.BOY_Date =#" & Forms!Update_Valdate!cboBOYDate & " # ; "


MsgBox "Valuation dates have been updated", vbOKOnly

DoCmd.Close acForm, "Update_Valdate"

DoCmd.SetWarnings True


End Sub

Open in new window

0
Comment
Question by:DB_newbie_NZ
3 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 125 total points
ID: 35012660
Why don't you just Bind your form to the zzvaldate table, and then bind the controls to the relevant fields? This would take care of those things automatically for you.
0
 

Author Comment

by:DB_newbie_NZ
ID: 35013034
Hi LSM, If i bind the form to the zzvaldate table is that not circular? - ie the form is bound to zzvaldate but zzvaldate is updated by data in the form.

zzvaldate can only be updated by the user entering dta in the form.

perhaps I'm getting this all wrong - will try the bound idea.
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 125 total points
ID: 35018986

<No Points wanted>

<If i bind the form to the zzvaldate table is that not circular? - ie the form is bound to zzvaldate but zzvaldate is updated by data in the form. >
Well this is not really referred to as being "circular" (Circular would be a table bound to itself, or a form bound to itself, which is impossible...)
Think of the form as a Pretty face put on the table.
;-)

What LSM suggested is known as a "Bound" form.
It is the way most forms are designed, unless you really need the full control that an "Unbound" form affords...
...And really want to keep track of controlling SQL queries, Recordsets, Events...etc...

I'll let you continue on with LSM...
;-)

JeffCoachman
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now