By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,963 Members | 1,714 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,963 IT Pros & Developers. It's quick & easy.

How to increment Customer_Id when add button is pressed Vb6 using Ms access

P: 1
Expand|Select|Wrap|Line Numbers
  1. Dim rs1 As New ADODB.Recordset
  2.  
  3. Private Sub cmdadd_Click()
  4. Adodc1.Refresh
  5.  
  6.  
  7.  
  8. End Sub
  9.  
  10. Private Sub cmdcancle_Click()
  11. If MsgBox("Are you sure you don't want to save the record ?", 4 + 32, Title) = vbNo Then
  12.         GoTo EXITPROCEDURE
  13.         Else
  14.             Unload Me
  15.             mainfom.Show
  16.     End If
  17.  
  18. EXITPROCEDURE:
  19.  
  20.     Exit Sub
  21. End Sub
  22.  
  23. Private Sub cmdgotomainform_Click()
  24. If MsgBox("Are you sure you want to GoTo Home ?", 4 + 32, Title) = vbNo Then
  25.         GoTo EXITPROCEDURE
  26.         Else
  27.             mainfom.Show
  28. Unload Me
  29.     End If
  30.  
  31. EXITPROCEDURE:
  32.     Exit Sub
  33.  
  34. End Sub
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45. Private Sub cmdsave_click()
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. If txtcustomername.Text = "" Then
  54. MsgBox "Please Enter Customer Name", vbExclamation, Title
  55. txtcustomername.SetFocus
  56. Exit Sub
  57. End If
  58.  
  59.  
  60. If txtdateofbirth.Text = Date Then
  61. MsgBox "Date of Birthday Cannot be today, Please Change it", vbExclamation, Title
  62. dateofbirth.SetFocus
  63. Exit Sub
  64. End If
  65.  
  66. If comboselectgender.Text = "-Select Gender-" Or comboselectgender.Text = "" Then
  67. MsgBox "Please Select a Gender", vbExclamation, Title
  68. comboselectgender.SetFocus
  69. Exit Sub
  70. End If
  71.  
  72. If txtaddress.Text = "" Then
  73. MsgBox "Please Enter the Address", vbExclamation, Title
  74. txtaddress.SetFocus
  75. Exit Sub
  76. End If
  77.  
  78. If txtphone.Text = "" Then
  79. MsgBox "Please Enter Phone/Mobile Number", vbExclamation, Title
  80. txtphone.SetFocus
  81. Exit Sub
  82. End If
  83.  
  84. If txtemail.Text = "" Then
  85. MsgBox "Please Enter E-Mail", vbExclamation, Title
  86. txtemail.SetFocus
  87. Exit Sub
  88. End If
  89.  
  90.  
  91.  
  92. Adodc1.Recordset.AddNew
  93. MsgBox "Record Sucessfully Added"
  94.  
  95.  
  96. End Sub
  97.  
  98.  
  99.  
  100.  
  101.  
  102.  
  103.  
  104.  
  105.  
  106. Private Sub dateofbirth_Change()
  107. txtdateofbirth = dateofbirth.Value
  108. End Sub
  109.  
  110. Private Sub txtaddress_KeyPress(KeyAscii As Integer)
  111. If KeyAscii = 13 And txtaddress.Text <> "" Then
  112. txtphone.SetFocus
  113. End If
  114. End Sub
  115.  
  116. Private Sub txtcustomername_KeyPress(KeyAscii As Integer)
  117. If KeyAscii = 13 And txtcustomername.Text <> "" Then
  118. dateofbirth.SetFocus
  119. ElseIf (KeyAscii < 65 And KeyAscii <> 8 And KeyAscii <> 32) Or (KeyAscii > 90 And KeyAscii < 97) Or (KeyAscii > 122) Then
  120. KeyAscii = 0
  121. MsgBox "Enter Letters Only!!"
  122. End If
  123. End Sub
  124.  
  125.  
  126.  
  127. Private Sub txtemail_KeyPress(KeyAscii As Integer)
  128. If KeyAscii = 13 And txtemail.Text <> "" Then
  129. cmdsave.SetFocus
  130. End If
  131. End Sub
  132.  
  133.  
  134. Private Sub txtphone_KeyPress(KeyAscii As Integer)
  135. If KeyAscii = 13 And txtphone.Text <> "" Then
  136. txtemail.SetFocus
  137. ElseIf (KeyAscii < 48 And KeyAscii <> 8) Or KeyAscii > 57 Then
  138. KeyAscii = 0
  139. MsgBox "Enter Digits Only!!"
  140. End If
  141. End Sub
  142.  
  143.  
  144. Private Sub Form_Load()
  145.  
  146.  
  147. txtcustomerid.Text = ""
  148. txtcustomername.Text = ""
  149. txtdateofbirth.Text = ""
  150. comboselectgender.Text = ""
  151. txtaddress.Text = ""
  152. txtphone.Text = ""
  153. txtemail.Text = ""
  154.  
  155.  
  156. End Sub
Jun 17 '15 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.