Reputation: 0 Apprentice
- New Members
- Active Posts:
- 8 (0.01 per day)
- 29-September 12
- Profile Views:
- Last Active:
- Oct 03 2012 02:54 AM
- Dream Kudos:
Posts I've Made
Posted 2 Oct 2012
Posted 1 Oct 2012The spaces and single quotes are the part of the syntax. the user defined variables are declared as
' " & amt & " 'What i want to do is a simple deposit transaction at bank. Balance should be added to the amount user want to deposit and new value shold be updated in database
Posted 1 Oct 2012IT IS NOT WORKING
Posted 30 Sep 2012THANK YOU
Posted 30 Sep 2012Can you tell us what error you get, it's not clear from your post?
Also a couple of points.
1. Have a look at using a naming convention for your variables. Something along the lines of strMyName would be a string type with the name MyName, intPointer would be an integer type, etc., etc. This makes your code easier to read for yourself and others. At the moment you have variables n, a, p and ty which mean nothing.
2. When declaring variables, either do it one on each line, or specify the type for each one. In your line "Dim accessconnect, n, a, num, ty As String", only ty is declared as string, the rest are declared as Variant type.
These are just some suggestions to help you in future.
Private Sub Command1_Click() 02 03 Dim conn1 As New ADODB.Connection 04 Dim cmd1 As New ADODB.Command 05 Dim rs1 As New ADODB.Recordset 06 Dim p As Integer 07 Dim accessconnect, n, a, num, ty As String 08 accessconnect = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=master;Data Source=POOJA-D4FD585E2\SQL2000" 09 conn1.ConnectionString = accessconnect 10 conn1.Open 11 cust_name = Text1.Text 12 cust_address = Text2.Text 13 contact_no = Val(Text3.Text) 14 accnt_numbr = Text4.Text 15 account_type = Text5.Text 16 17 cmd1.ActiveConnection = conn1 18 cmd1.CommandText = " insert into customer(customer_name,customer_address,customer_phn,cutomer_dob,account_number,account_type) values(' " & cust_name & " ' , ' " & cust_address & " ',' " & contact_no & " ' , ' " & DTPicker1.Value & " ',' " & accnt_numbr & " ' , ' " & account_type & " ')" 19 Set rs1 = cmd1.Execute 20 conn1.Close 21 MsgBox ("DATABASE UPDATED SUCCESSFULLY") 22 End Sub 23 24 Private Sub Text1_Validate(Cancel As Boolean) 25 cust_name = Text1.Text 26 If cust_name = (" ") And (Len(cust_name) < 3) Then 27 MsgBox ("Enter valid customer name") 28 End If 29 End Sub 30 31 Private Sub Text2_Validate(Cancel As Boolean) 32 cust_address = Text2.Text 33 If cust_address = (" ") And (Len(cust_address) < 3) Then 34 MsgBox ("Enter valid address") 35 End If 36 End Sub 37 38 Private Sub Text3_Validate(Cancel As Boolean) 39 contact_no = Val(Text3.Text) 40 If Not IsNumeric(contact_no) And contact_no = (" ") And (Len(contact_no) < 10) Then 41 MsgBox "Please enter numbers only." 42 End If 43 End Sub 44 45 46 Private Sub Text4_Validate(Cancel As Boolean) 47 accnt_numbr = Text4.Text 48 If accnt_numbr = (" ") Then 49 MsgBox ("Account number cannot be null ") 50 End If 51 End Sub 52 53 Private Sub Text5_Validate(Cancel As Boolean) 54 account_type = Text5.Text 55 If account_type = (" ") Then 56 MsgBox ("Enter a type of account ") 57 End If 58 End Sub
The problem is when i get input the code does not validate i.e if i leave all text fields empty then also the database is updated
- Member Title:
- New D.I.C Head
- Age Unknown
- Birthday Unknown
Poojaaa hasn't added any friends yet.