Unbound Data Entry Form (1 Viewer)

cagay

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 14, 2005
Messages
12
Is anyone there who can show me a db sample of unbound data entry form. I want to control the builtin auto save of Access, because sometimes I don't want to save the data of my form..

Thanks,
cagay
 

mousemat

Completely Self Taught
Local time
Today, 06:14
Joined
Nov 25, 2002
Messages
233
cagay said:
Is anyone there who can show me a db sample of unbound data entry form. I want to control the builtin auto save of Access, because sometimes I don't want to save the data of my form..

Thanks,
cagay


Try this one, I have used this a few times. Its not perfect but will help you get started!
 

Attachments

  • Unbound.zip
    28.5 KB · Views: 149

Mile-O

Back once again...
Local time
Today, 06:14
Joined
Dec 10, 2002
Messages
11,316
cagay said:
I want to control the builtin auto save of Access, because sometimes I don't want to save the data of my form.

You can use the form's Before_Update() event to prevent dat being saved; there's absolutely no need for unbound data entry forms.
 

cagay

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 14, 2005
Messages
12
Form - Before_Update

SJ McAbney said:
You can use the form's Before_Update() event to prevent dat being saved; there's absolutely no need for unbound data entry forms.

Hi SJ McAbney,

Can you show me the right code, I don't now much yet in code..

Thanks for your time..
cagay
 

cagay

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 14, 2005
Messages
12
Thank you mousemat,

I will try to adopt your approach..
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:14
Joined
Feb 19, 2002
Messages
43,565
As has already been suggested - You don't need unbound forms to control when data is saved - you just need to use the FORM's BeforeUpdate event properly.
 

cagay

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 14, 2005
Messages
12
BeforeUpdate Event

Pat Hartman said:
As has already been suggested - you just need to use the FORM's BeforeUpdate event properly.


Pat,

My Access level is very beginner, infact this is my very first DB to make. Can you guide me, what is the code to be use in the "BeforeUpdate" of my form!..

Thanks,
cagay
 

Mile-O

Back once again...
Local time
Today, 06:14
Joined
Dec 10, 2002
Messages
11,316
Code:
Private Sub Form_BeforeUpdate()
    If MsgBox("Do you wish to save the changes?", vbQuestion+vbYesNo,"Save?") = vbNo Then
        Me.Undo
    End If
End Sub
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:14
Joined
Feb 19, 2002
Messages
43,565
If you have edits that involve more than one field or null values, the only safe place for the edits is the FORM's BeforeUpdate event. If one of the edits fails, you don't want to undo all the changes that the user has made to the form so you can't use Me.Undo but you do want to stop Access from saving the record and closing the form so you cancel the update event with:
Cancel = True
BTW - any event that takes a Cancel argument can be cancelled. Events that do not take a cancel argument (such as the form's close event) cannot be cancelled. Sample edit code might be:

Code:
If IsNull(Me.SomeField) Then
    Msgbox "SomeField is null.  Please enter a value", vbOKOnly
    Me.SomeField.SetFocus
    Cancel = True
End If
If Me.SomeField > 55 And Me.SomeOtherField > 22 Then
Else
    Msgbox "SomeField and/or SomeOtherField are out of range.  Please fix.",vbOKONLY
    Cancel = True
    Me.SomeField.SetFocus
End If
 

cagay

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 14, 2005
Messages
12
Well, thank you all guys..

Been trying the code of MJ McAbney, it also tiggers when I click my "AddRecord" button..maybe because it is "beforeupdate" event..I guess I don't need a button, just make my form as data entry = yes..
 

cagay

Registered User.
Local time
Yesterday, 22:14
Joined
Aug 14, 2005
Messages
12
Pat Hartman said:
Sample edit code might be:

Code:
If IsNull(Me.SomeField) Then
    Msgbox "SomeField is null.  Please enter a value", vbOKOnly
    Me.SomeField.SetFocus
    Cancel = True
End If
If Me.SomeField > 55 And Me.SomeOtherField > 22 Then
Else
    Msgbox "SomeField and/or SomeOtherField are out of range.  Please fix.",vbOKONLY
    Cancel = True
    Me.SomeField.SetFocus
End If


Hello Pat,
I just want to make some clarification, "Me.SomeField", if I will replace this to one of my table field, how about the other fields. Also I think this code is useful on "required" field..

I just want a code to put behind my "SAVE" button to either save the record/data or no and close the form..

cagay,
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 01:14
Joined
Feb 19, 2002
Messages
43,565
The ONLY line of code that should go in the save button's click event is:

DoCmd.RunCommand acCmdSaveRecord

ALL editing and prompting belongs in the FORM's BeforeUPdate event as I said earlier.
 

Users who are viewing this thread

Top Bottom