Question AutoNumber in access... ERROR

Haseo

Member
Joined
Jul 16, 2012
Messages
16
Programming Experience
Beginner
i have a problem about the autonumber for my ID in database....

i try to run but there's no number come out with my booking no text....type a number before it will show to my database..


i just need to change the properties of my ID autonumber to a number and it will come out manually....

the image will show the error..

here's the code


Private Sub btnaddnew_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnaddnew.Click
Dim cmd As New OleDb.OleDbCommand


If Not cnn.State = ConnectionState.Open Then


cnn.Open()


End If


cmd.Connection = cnn


If Me.txtID.Tag & "" = "" Then
cmd.CommandText = " INSERT INTO reserv (id, checkcon, datebook, Occasion, dateevent, octime, Place, Cperson, Phone, Package, Quote) " & _
" VALUES(" & Me.txtID.Text & ",'" & Me.txtcheckcon.Text & "','" & _
Me.dtpdatebooked.Text & "','" & Me.cbboccasion.Text & "','" & _
Me.dtpdateevent.Text & "','" & Me.txttime.Text & "','" & _
Me.txtplace.Text & "','" & Me.txtcperson.Text & "','" & _
Me.txttell.Text & "','" & Me.txtpackage.Text & "','" & _
Me.txtquote.Text & "')"


cmd.ExecuteNonQuery()
MsgBox("Record Save")


End If


RefreshData()


Me.btnclear.PerformClick()


cnn.Close()


End Sub


sorry for a lot of question i'm newbie in this language...

can anyone give some sample code or advice about this
 

Attachments

  • access.jpg
    access.jpg
    34.2 KB · Views: 38
  • no autonumber come out.jpg
    no autonumber come out.jpg
    18.4 KB · Views: 32
  • error.jpg
    error.jpg
    93.4 KB · Views: 35
It's AUTO!!!!!!!

You cannot do this ....

If Me.txtID.Tag & "" = "" Then

cmd.CommandText = " INSERT INTO reserv (id, checkcon, datebook, Occasion, dateevent, octime, Place, Cperson, Phone, Package, Quote) " & _
" VALUES(" & Me.txtID.Text & ",'" & Me.txtcheckcon.Text & "','" & _

If you want to determine the values for the ID then you have to use an ordinary number column. Autonumber will apply 1 to the first row, 2 to the second row, etc. You cannot change this.
 
It's AUTO!!!!!!!

You cannot do this ....

If Me.txtID.Tag & "" = "" Then

cmd.CommandText = " INSERT INTO reserv (id, checkcon, datebook, Occasion, dateevent, octime, Place, Cperson, Phone, Package, Quote) " & _
" VALUES(" & Me.txtID.Text & ",'" & Me.txtcheckcon.Text & "','" & _

If you want to determine the values for the ID then you have to use an ordinary number column. Autonumber will apply 1 to the first row, 2 to the second row, etc. You cannot change this.



can you correct my code?? or give me sample code for that..
 

Similar threads

Back
Top