form processing

I'm new to VB and MS access.
I want to create a form that when I press ok, the form is saved and when I press cancel
the form is not saved.
see the code below, it is not completed but this is all I came up

intRes = MsgBox("", vbOKCancel + vbQuestion, )

Select Case intRes

        Case vbOK

        Case vbCancel
End Select

I want to know what should I write after " case vbok" and "case vbCancel"

Who is Participating?
Bob LearnedConnect With a Mentor Commented:
You could create a small routine to save the data:

Private Sub SaveData()

Dim dbData As Database
Dim rsRecordset As Recordset

   Set dbData = OpenDatabase("Database.mdb")
   Set rsRecordset = dbData.OpenRecordset("Table")
   With rsRecordset
         !Name = Name
         !Address = Address
         !CityStateZip = CityStateZip
   End With

End Sub

Name, Address, and CityStateZip are sample textboxes on a form.  The code would go in the form, and you would need to change the field names, and textbox names to match what your form and recordset would really have.

For this to work, you are going to need add a reference to Microsoft DAO 3.5 Object Library for Access 97 or Microsoft DAO 3.6 Object Library for Access 2000.
What form do you want it to save under
What form do you want it to save under
This is a lot of code for 50 points!!!
The new generation of project management tools

With’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

andy98Author Commented:
I have increased my points to 200 gilbertkid ...
All I want is to accept any data enterred in the form
if the ok button pressed or not to accept the data
entered in the form if the cancel buttom is pressed...
Lets see if you can help, I added 150 more points...

case vbOk:

   your code to save the data (to a file, database or whatever)

case vbCancel:
'do nothing, in both cases you will
'probably unload the form

end select

'unload the form
Unload Me
set yourFormsName = nothing
It would be nice if you told us why an answer is rejected.

Do you want to save your data in a MSAccess database?
All Courses

From novice to tech pro — start learning today.