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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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!!!
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...
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!


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
Bob LearnedCommented:
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.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It would be nice if you told us why an answer is rejected.

Do you want to save your data in a MSAccess database?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.