Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / May 2008

Tip: Looking for answers? Try searching our database.

Make record only on "ADD" button

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 29 May 2008 12:22 GMT
Hi.. I'm having a problem with my form.. It has 3 textboxs connected to a
table.. On the form options "data entry" = yes..
The problem i have it's that i made this form to add those 3 field to a
table and i only want to add them when the user clicks the "ADD" button.. but
what is happening is that automaticly when the user just clicks one of those
3 textboxs, not even needs to write something, if i close it on the X (its a
popup form) or if i click the "CANCEL" button when i check the table a new
registry was made.. I dont want that.. i only want the record to be made when
the user clicks the "ADD" button with this code:

Private Sub Command1_Click()
    If IsNull(DLookup("Park", "Query_park")) = False Then
               MsgBox "Park already created!"
    Else
If IsNull(parkname) = True Or IsNull(area) = True Or IsNull(Panel) = True Then
MsgBox "ERROR:Fill every field"
Else
   If Me.Dirty Then Me.Dirty = False
DoCmd.RunCommand acCmdRecordsGoToNew
MsgBox "Parque adicionado!"
DoCmd.Close                            
DoCmd.OpenForm "Form2"
End If
End If
End Sub

How can i solve this problem??
I cant have blank records or Wrong records on the table connected to this
form because on other form i have a combobox looking up for the "parkname"
column of the table..

Thanks
Nuno
Jeff Boyce - 29 May 2008 12:36 GMT
By design, when you leave (close) an Access form that is "bound" to a table,
the changes you've made are saved.

If you are using a form with "data entry = yes", then the record you've
added is saved.

If you wish not to save a record, and you want to ensure that all fields are
filled, you could add code to a BeforeUpdate event that validates first and
uses Undo to remove the entries if validation fails.

Signature

Regards

Jeff Boyce
www.InformationFutures.net

Microsoft Office/Access MVP
http://mvp.support.microsoft.com/

Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/

> Hi.. I'm having a problem with my form.. It has 3 textboxs connected to a
> table.. On the form options "data entry" = yes..
[quoted text clipped - 29 lines]
> Thanks
> Nuno
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.