data entry

D

Denver

i have a Data Entry Form bound for a query..
i have a Save Button....
even i dont have any data entered yet it saves when i clicked the Save button.

is there any code that prompt to user that they need to enter a data prior
saving
or any like scenario? what could be look like?

thanks anyway

denver
 
J

Jeanette Cunningham

Hi Denver,
how do you know that it saves when there is no data entered?
What is the code on your save button?
For example if you have code like this on your save button:

If Me.Dirty = True Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name

That code would close the form if no data was entered, but it would not save
the non-existing data in the table used in the query for the form.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
M

Mike Painter

You can set the required property to Yes on any or all of the fields on your
form.
This will pop up a warning when they try to save with those fields not
filled.
If you don't like the message you can intercept it and pop one of your own.
 
D

Denver

thanks for your time and great idea, i appreciate...
but sorry i did not mention that iam not using any codes for my Save button
i am using the Macro -Save-MsgBox....

can anyone show me what code be excatly if i am going to use VBA?
i have set properties of my data entry form to NO- Allow Deletions and No-
AllowEdits
YES-Allow Additions Yes - Data Entry...

thanks

denver
 
J

Jeanette Cunningham

Denver are you using Access 2007?
Your form's data settings are a little unusual.
If you want user to add new records, you would usually set allow edits to
Yes.
Setting Data entry to yes makes the form open at a new record.
It will make more sense to talk about what you intend for your form.
Why do you have a save button?
Do you want users to have the option of not saving data they have gone to
the trouble of typing on the form?

If you want to use VBA instead of the macro,
use code like this:

If Me.Dirty = True Then
Me.Dirty = False
End If
DoCmd.Close acForm, Me.Name

That code would close the form if no data was entered, otherwise it would
save any data entered and then close the form

A form becomes dirty after a user types something in the form, even if later
they delete their typing.
Setting Dirty to False makes Access write the data to the table.

Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 

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