Form saving data before submitted

RyanB

Registered User.
Local time
Today, 09:03
Joined
Jul 13, 2004
Messages
53
Hi All,

I have a form where users fill out information and then press a submit button when completed, my problem is that the form is saving the data as it goes so when someone stops filing in a form halfway through the half filled form is saving in the database and its making it a mess.

so my question is how do I stop it doing this???

Cheers,

Ryan
 
Search here for validation, there have been numerous posts on the subject
 
thanks,

I looked through the search and there were so many and it seems to cover a wide range of things...

I'm not fussed if some fields arn't filled in, i just want it not to save if the 'submit' button isn't pressed.

Can anyone provide any info which doesn't have me searching through 100's of threads or even a link to a thread which talks about when i'm looking for would be great.

Cheers,

MB
 
I would make a command button for save or cancel and probably get rid of the navigation button too. Also set the cycle to current record to avoid the tab and enter.

Make a command button and paste the code below On Click Event.

Dim strMsg As String, strTitle As String

strMsg = "Do You Want To Save This Record?"
strTitle = " Save Record ?"

If MsgBox(strMsg, vbQuestion + vbYesNo, strTitle) = vbNo Then
Me.Undo

End If

DoCmd.GoToRecord , , acNewRec


Michael
 
Or alternative go for an unbound form then you code the save button to save. If the user doesn't click the button, nothing goes to the db. If they do, you validate their data to make sure its correct and if it is then its saved... if not the loving error message appears...

Its an option :)


Vince
 
Thanks ecniv, thats what i'm looking for!!

no one more question... how do I make it unbound?!?

Thanks for all the help :-)

RB
 
RyanB said:
Thanks ecniv, thats what i'm looking for!!

no one more question... how do I make it unbound?!?

Thanks for all the help :-)

RB

I hope you are joking. Sounds like more coding pain than coding the button above. Any chance you are setting focus away from your main form?
What are your users doing? they must be moving off the main form or maybe you have some other code running which forces an update???
 
I don't understand, I don't believe I have anything in my code which is making the records save mid-form, the users are filling in the form properly its just that if someone would say close the window mid way through we get a half filled in records and requires me to keep deleting these false records.

Here is the code I have so far:

Option Compare Database

Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
Call Form_reset
End Sub

Private Sub netacc_AfterUpdate()
If Netacc.Value = True Then
Page50.Visible = True
Else
Page50.Visible = False
End If
Call NewUserChk_Click
End Sub

Private Sub comacc_AfterUpdate()
If comacc.Value = True Then
Page51.Visible = True
Else
Page51.Visible = False
End If
End Sub

Private Sub NewUserChk_Click()
If NewUserChk.Value = True Then
Comexuse.Enabled = False
netexuse.Enabled = False
netnul.Enabled = True
comnul.Enabled = True

End If
If NewUserChk.Value = False Then
netnul.Enabled = False
comnul.Enabled = False
Comexuse.Enabled = True
netexuse.Enabled = True
End If

End Sub



Private Sub Command110_Click()
On Error GoTo Err_Command110_Click
If tncchk.Value = False Then
MsgBox "Please read the Network Standards and Policies"
Else
Call Value_Conversion
MsgBox "Your request has been submitted and labeled Request Number " & Val(requestno)
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.GoToRecord , , acNewRec
Call Form_reset
End If
Exit_Command110_Click:
Exit Sub

Err_Command110_Click:
MsgBox Err.Description
Resume Exit_Command110_Click

End Sub

Private Sub Value_Conversion()

date1.Value = Text61.Value
time1.Value = Text62.Value
diracc1.Value = Combo81.Value & " " & diracc1.Value
diracc2.Value = Combo83.Value & " " & diracc2.Value
diracc3.Value = Combo84.Value & " " & diracc3.Value
comp1.Value = comp1opt.Value & " " & comp1.Value
comp2.Value = comp2opt.Value & " " & comp2.Value
comp3.Value = comp3opt.Value & " " & comp3.Value
End Sub

Private Sub Form_reset()

Netacc.Value = False
Call netacc_AfterUpdate
comacc.Value = False
Call comacc_AfterUpdate
NewUserChk.Value = False
Call NewUserChk_Click
Combo81.Value = Null
Combo83.Value = Null
Combo84.Value = Null
comp1opt.Value = Null
comp2opt.Value = Null
comp3opt.Value = Null
tncchk.Value = False
End Sub


Pretty new to access, so learning as I go.

Hope someone can point me in the right direction, thanks again for all the help :-)

Ryan.
 
Just to add on to this thread and to ask a question myself as well.

Ryan, when you close the form, the data in the fields will be stored in the table. This happens regardless of you adding any code to save the data. This is a normal feature, I guess.

I've the same problem as you and I've used the code posted by Ukraine82 in his earlier post. It works fine except for this line,

Code:
DoCmd.GoToRecord , , acNewRec

When I click Yes to save the record, I get a runtime error of 2105. It says I can't go to a specified record and I may be at the end of a RecordSet. Does anyone know how do I go about solving this error?

Ryan you can try out the code as well as I think it can solve your problem

-Swee
 
Ukraine82 said:
I would make a command button for save or cancel and probably get rid of the navigation button too. Also set the cycle to current record to avoid the tab and enter.

Ryan- Now that you described the users pattern of data entry it make sense.

I would add the code to the forms beforeupdate event. This way even if they navigate off the record (using record selector or close) it will fire. So your exit or main menu button simply closes the form. But before the form actually closes, the beforeupdate event of the form will trigger and the update message box will appear.

Also- If a field MUST contain data, THEN go to the field in the table and set the Required property to YES. This way the user can not save that record unless ALL REQUIRED fields were entered. Then you don't have to check the required fields using code...unless you want to present your users with a more user friendly error message or tell them all the missing fields using one message vs. having them find out one-by-one.

But make sure you set ONLY the minimum amount of fields to required, such as name and city/state/zip or name and account number, etc..
If you make too many fields required, your users may start a civil war. "I didn't have to enter that before..."
 
Hi All,

Thanks norm that worked great, all appears to functioning correctly now!

allthought I had the same problem with the DoCmd.GoToRecord , , acNewRec command, so I removed it and all appears to be working fine now :)

Ryan
 

Users who are viewing this thread

Back
Top Bottom