VB6 Add a record to MySQL with cancel option

Posted on 2011-10-27
Medium Priority
Last Modified: 2013-12-25
I want to do simple record manipulation.  I have 3 buttons on a form:  New, Save, Cancel.

If I start with this sub (connection works correctly), what's the proper Save/Cancel?

Private Sub btnNewOne_Click()
     txtField1.text = ""
     txtField2.text = ""
     txtField3.text = ""
End Sub

Open in new window

Question by:kkbenj
LVL 14

Accepted Solution

Brook Braswell earned 2000 total points
ID: 37039573
I would suggest a popup screen or form to go along with this process...

on New ' show the form or perhaps frame

on cancel or save...hide the frame

I would also encourage data validation in the save...
Perhaps require field1 be populated...
Private Sub btnNewOne_Click()
     txtField1.text = ""
     txtField2.text = ""
     txtField3.text = ""
     frNewData.Visible = True
End Sub

Private Sub btnSaveOne_Click()
     if trim(txtfield1.Text) = "" then
        msgbox "Please enter a value in Field 1" 
        exit sub
     end if  
     goRecSet!Field1 = txtfield1.text
     goRecSet!Field2 = txtfield3.text
     goRecSet!Field3 = txtfield4.text
     frNewData.visible = false 
End Sub

Private Sub btnCancel_Click()
     ' return values to previous row ?
     if goRecSet.recordcount > 0 then
        goto LeaveNow
     End If 
     txtField1.text = goRecSet!Field1
     txtField2.text = goRecSet!Field2
     txtField3.text = goRecSet!Field3
     frNewData.visible = false
End Sub

Open in new window


Author Closing Comment

ID: 37039856
It's like you read my mind.  Thanks!

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses

862 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