Hi,
I have another problem with ADO vb 6
The problem is I try to connect the Ms Access Database using ADO.
The code I use is
when I reach rsqt.Open sqlqt, 1, 2 it says
Runtime error 3001 - Arguments are of the wrong type, are out of acceptble range or are in conflict with one another.
When I use the SQl in MS access, it works fine. What is the problem from the following code.
Private Sub Qrtbrkdown_Click()
Dim qrt1, bud As String
Dim k, amt As Integer
Dim rs, rs1, rsq1, rsq2t, rsqit1, rsqt As New ADODB.Recordset
Dim sqlqt, sqlq2t, sqlqit, sqlqit1 As String
Quarter.Visible = True
qrt1 = InputBox("Which year do you want allocate quarterly?", "Year")
Label7.Caption = qrt1 ' Year
Set conn = New ADODB.Connection
conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\moa database\fao_projectdb.mdb;Persist Security Info=False")
Set rsqt = CreateObject("adodb.recordset")
conn.BeginTrans
sqlqt = "select amount from temp_ann where yr= '" & qrt1 & "' and prjid = '" & prjNo.Text & "'"
conn.Execute sqlqt
rsqt.Open sqlqt, 1, 2
conn.CommitTrans
Label9.Caption = 200 ' Annual Budget
Set rsq2t = CreateObject("adodb.recordset")
conn.BeginTrans
sqlq2t = "select budallid, amount from temp_ann where yr= '" & qrt1 & "' and prjid = '" & prjNo.Text & "'"
rsq2t.Open sqlq2t, 1, 2
conn.CommitTrans
bud = rsq2t.Fields(0)
For k = 1 To 4
qurtamt(k) = InputBox("Amount for Quarter " & k & ",", "Quarter")
Next k
conn.BeginTrans
sqlqit = "insert into temp_Qur_Bud(budallid,quarter,amount) values('" & bud & "','" & qur(k) & "'," & qurtamt(k) & ")"
rsqt.Open sqlqit, 1, 2
conn.CommitTrans
sqlqit1 = "select * from temp_ann where prjid = '" & prjNo.Text & "'"
rsqt.Open sqlqit1, conn, 1, 2
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\moa database\fao_projectdb.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = sqlqit1
Adodc1.Refresh
Set budgetbrk.DataSource = Adodc1
qrtbudget.Visible = True
rsqt.close
End Sub
Thank u
I have another problem with ADO vb 6
The problem is I try to connect the Ms Access Database using ADO.
The code I use is
when I reach rsqt.Open sqlqt, 1, 2 it says
Runtime error 3001 - Arguments are of the wrong type, are out of acceptble range or are in conflict with one another.
When I use the SQl in MS access, it works fine. What is the problem from the following code.
Private Sub Qrtbrkdown_Click()
Dim qrt1, bud As String
Dim k, amt As Integer
Dim rs, rs1, rsq1, rsq2t, rsqit1, rsqt As New ADODB.Recordset
Dim sqlqt, sqlq2t, sqlqit, sqlqit1 As String
Quarter.Visible = True
qrt1 = InputBox("Which year do you want allocate quarterly?", "Year")
Label7.Caption = qrt1 ' Year
Set conn = New ADODB.Connection
conn.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\moa database\fao_projectdb.mdb;Persist Security Info=False")
Set rsqt = CreateObject("adodb.recordset")
conn.BeginTrans
sqlqt = "select amount from temp_ann where yr= '" & qrt1 & "' and prjid = '" & prjNo.Text & "'"
conn.Execute sqlqt
rsqt.Open sqlqt, 1, 2
conn.CommitTrans
Label9.Caption = 200 ' Annual Budget
Set rsq2t = CreateObject("adodb.recordset")
conn.BeginTrans
sqlq2t = "select budallid, amount from temp_ann where yr= '" & qrt1 & "' and prjid = '" & prjNo.Text & "'"
rsq2t.Open sqlq2t, 1, 2
conn.CommitTrans
bud = rsq2t.Fields(0)
For k = 1 To 4
qurtamt(k) = InputBox("Amount for Quarter " & k & ",", "Quarter")
Next k
conn.BeginTrans
sqlqit = "insert into temp_Qur_Bud(budallid,quarter,amount) values('" & bud & "','" & qur(k) & "'," & qurtamt(k) & ")"
rsqt.Open sqlqit, 1, 2
conn.CommitTrans
sqlqit1 = "select * from temp_ann where prjid = '" & prjNo.Text & "'"
rsqt.Open sqlqit1, conn, 1, 2
Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\moa database\fao_projectdb.mdb;Persist Security Info=False"
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = sqlqit1
Adodc1.Refresh
Set budgetbrk.DataSource = Adodc1
qrtbudget.Visible = True
rsqt.close
End Sub
Thank u