Please Help

mozaharul

Active Member
Licensed User
I have created a small program having 4 tabs. On the 1st tab there is 5 variables. The following codes are to save the values of 5 variables :

Sub Globals
'Declare the global variables here.
Dim i,cb1,cb2
End Sub

Sub App_Start
Form1.Show
'Setting connection to the database
dbpath="C:\Documents and Settings\mozaharul\Desktop"
con.New1
cmd.New1("",con.Value)
con.Open("data source =" & dbpath & "\kamlapur.sl3")
TFields="strat numeric, cluster numeric, struct numeric, hhid numeric,hpid numeric"
Txt="create table if not exists geo (" & TFields & ")"
cmd.CommandText=Txt
cmd.ExecuteNonQuery
'-------------------------------------------------------
'Add columns to the table "table1"

table1.AddCol(cnumber,"Staturm",1)
table1.AddCol(cnumber,"Cluster",1)
table1.AddCol(cnumber,"Structure",1) 'Account Number must be unique.
table1.AddCol(cnumber,"HH No.",1)
table1.AddCol(cnumber,"HH ID",1)
'----------------------------------------------------------
txthhidtn.Enabled=false
Cmbrand.Add ("1 - Not randomised")
Cmbrand.Add("2 - Included in study 1")
Cmbrand.Add("3 - Included in study 2")
Cmbrand.Add("4 - Included in study 3")

CmbStocc.Add ("1 - Owner")
CmbStocc.Add("2 - Tenant (renting house)")
CmbStocc.Add("3 - Provided for free")
CmbStocc.Add("4 - Squatter")
CmbStocc.Add("5 - Other")

For i = 1 To 7
cmbstar.Add (i)
Next
'Adding Tab pages to the Form
tbc.New1("form1",5,10,230,250)
tbc.AddTabPage("Geo Info.")
tbc.AddTabPage("Personal Info.")
tbc.AddTabPage("Asset Owned Page1")
tbc.AddTabPage("Asset Owned Page2")
tbc.AddControl("panel1",0,0,0)
tbc.AddControl("panel2",1,0,0)
tbc.AddControl("panel3",2,0,0)
tbc.AddControl("panel3",2,10,6)
tbc.AddControl("panel4",2,10,32)
tbc.AddControl("panel5",2,10,58)
tbc.AddControl("panel6",2,10,84)
tbc.AddControl("panel7",2,10,110)
tbc.AddControl("panel8",2,10,136)
tbc.AddControl("panel9",2,10,162)
tbc.AddControl("panel10",2,10,188)
tbc.AddControl("panel11",3,10,6)
tbc.AddControl("panel12",3,10,32)
tbc.AddControl("panel13",3,10,58)
tbc.AddControl("panel14",3,10,84)
tbc.AddControl("panel15",3,10,110)
tbc.AddControl("panel16",3,10,136)
tbc.AddControl("panel17",3,10,162)
'tbc.AddControl("panel18",3,10,185)
End Sub

Sub Cmbstar_SelectionChanged (Index, Value)
Select index
Case 0
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 1 To 27
cmbclu.Add (i)
Next
Case 1
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 1 To 14
cmbclu.Add (i)
Next
Case 2
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 1 To 178
cmbclu.Add (i)
Next
Case 3
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 4 To 14
cmbclu.Add (i)
Next
Case 4
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 1 To 82
cmbclu.Add (i)
Next
Case 5
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 5 To 58
cmbclu.Add (i)
Next
Case 6
cmbclu.SelectedIndex = -1
cmbclu.Clear
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
For i = 1 To 89
cmbclu.Add (i)
Next
End Select
End Sub
Sub txtiid_KeyPress (key)
If Not (IsDigit(key)) AND Asc(key) <> 8 Then
txtiid.IgnoreKey
txtiid.Focus
Else
If StrLength (txtiid.Text) = 2 Then
timer1.Enabled=true
End If
End If
End Sub

Sub txthhid_KeyPress (key)
If Not (IsDigit(key)) AND Asc(key) <> 8 Then
txthhid.IgnoreKey
txthhid.Focus
Else
If StrLength (txthhid.Text) = 2 Then
txtiid.Focus
End If
End If
End Sub

Sub Cmbstar_LostFocus
If cmbstar.SelectedIndex >= 0 Then
cb1=cmbstar.Item (cmbstar.SelectedIndex)
End If
End Sub

Sub txtiid_LostFocus
txthhidtn.Text = cb1 & cb2 & txthhid.Text & txtiid.Text
End Sub

Sub Timer1_Tick
Timer1.Enabled=False
txthhidtn.SelectionLength = 10
txthhidtn.Text = cb1 & cb2 & txthhid.Text & txtiid.Text
txtohh.Focus
End Sub

Sub Cmbclu_LostFocus
If cmbclu.SelectedIndex >= 0 Then
cb2=cmbclu.Item (cmbclu.SelectedIndex)
End If
End Sub

Sub Cmbclu_GotFocus
txthhid.Text = ""
txtiid.Text=""
txthhidtn.Text=""
End Sub

Sub msave_Click
If cmbstar.SelectedIndex = -1 Then
Msgbox ("No staturm Selected","Error")
cmbstar.Focus
Else If cmbclu.SelectedIndex= -1 Then
Msgbox ("No Cluster Selected","Error")
cmbclu.Focus
Else If txthhid.Text="" Then
Msgbox ("No Structure Selected","Error")
txthhid.Focus
Else If txtiid.Text="" Then
Msgbox ("No HH No. Selected","Error")
txtiid.Focus
Else If txthhidtn.Text="" Then
Msgbox ("No HH ID Selected","Error")
txthhidtn.Focus
Else
cmd.CommandText = "insert into geo values(cmbstar.Item(cmbstar.SelectedIndex)","cmbclu.Item(cmbclu.SelectedIndex)","txthhid.Text","txtiid.Text","txthhidtn.Text)"
cmd.ExecuteNonQuery
End If
End Sub

Sub Form1_Close
con.Close
End Sub

the codes are executed without any error, but no data is being saved in the "geo" table in the desktop.

Could anyone help finding the error in the syntax?
 

Erel

Administrator
Staff member
Licensed User
Add msgbox(cmd.CommandText). You will see that you don't get what you expect.
The ampersand (&) is the concatenation character:
somestring = "sdfsdfsdf" & "Sfesfe" & textbox1.text
 
Top