I need help .now am using vb6
how to icrement values in database(ms acesss).
if user click the check box then
authomatically increment the database value 1 to 2
how it is posible.pls give a sutable solution

hi, you have two set one of the field to autonumber. then your checkbox, you need to make a code for that the when the user clicks on it, it will add record to the database.

search google on how to do it like: "msaccess vb6 tutorial" or try this link: http://www.profsr.com/vb/vbintro.htm

Under the checkbox do the following -

Dim xRecCount As Integer

xRecCount = rsData.RecordCount

xRecData = xRecData + 1

Can you show us your codes? Passing value from VB6 to MSAccess will not work unless you have correct connection strings etc. If you have connected VB6 to Access correctly then it will be easy to pass values to database.

Snairsumith, have a look at what I have posted above. Under say a command button click event add the code as follow -

Command1_Click ()
Dim xRecCount As Integer
xRecCount = rsData.RecordCount
xRecData = xRecData + 1

Data1!MyIdField = xRecData
'Other data to be added code here


This is assuming that you are asking for an increment on the next data record to be added...?

Id you only want to change a value in a field where the value is currently 1, then do the following -

Dim xChange As Integer

xChange = Data1!MyFieldToChangeValue

xChange = xChange + 1

Data1!MyFieldToChange = xChange


Did this answer your question?

This article has been dead for over six months. Start a new discussion instead.