What I'm trying to accomplish-
I'm trying to use access to append info such as form #, state, transaction type and a few other variables, into a temporary table. This table will then be exported to Excel.
Questions
Solved
Amit
Dim db As Database
Dim query As QueryDef
Dim stDocName As String
Dim stTranstype As String
Dim stState As String
Dim qry As String
Set db = CurrentDb
Dim tmpbl As Recordset
Dim T1 As Recordset
Dim Transtype As Recordset
Dim SSV As Recordset
Dim insert As Recordset
SSV.OpenRecordset = db.OpenRecordset("state specific variations", dbOpenSnapshot) Transtype.OpenRecordset = db.OpenRecordset("Trans type", dbOpenSnapshot) T1.OpenRecordset = db.OpenRecordset("Table1", dbOpenSnapshot)
tmpbl.OpenRecordset = db.OpenRecordset("temptbl", dbOpenSnapshot)
stState = cmbState.Text
stTranstype = cmbTrans.Text
Do While Not T1.EOF
qry = "INSERT INTO tmpbl ( [Insert No], [Insert Replaced], [description of communication], [type of transaction], State )" qry = qry & " SELECT T1![Insert No], Replacement![Insert Replaced], T1![description of communication], Transtype!Abbrev, T1!State"
qry = qry & " FROM ((Transtype INNER JOIN T1 ON Transtype!ID = T1![type of transaction]) LEFT JOIN Replacement ON T1![Insert No] = Replacement![Insert Number]) LEFT JOIN SSV ON T1![Insert No] = SSV![state specific form]"
qry = qry & " WHERE (((Transtype!Abbrev) Like "*" & [trans type] & "*") AND ((Table1.State) Like "--" Or (T1.State) Like "*" & [staten] & "*"));
Loop
DoCmd.RunSQL qry
SSV.Close
Transtype.Close
T1.Close
tmpbl.Close
I'm trying to use access to append info such as form #, state, transaction type and a few other variables, into a temporary table. This table will then be exported to Excel.
Questions
- how do you increment a recordset running a query with 2 joins?
- is there a difference in the application in dao and ado, like ado should be used for x and dao should be used for y?
Solved
- how do you do queries in line? I'm trying to do a fairly large query but so i can't store it into a string any ideas?
- what is a type mismatch error
Amit
Dim db As Database
Dim query As QueryDef
Dim stDocName As String
Dim stTranstype As String
Dim stState As String
Dim qry As String
Set db = CurrentDb
Dim tmpbl As Recordset
Dim T1 As Recordset
Dim Transtype As Recordset
Dim SSV As Recordset
Dim insert As Recordset
SSV.OpenRecordset = db.OpenRecordset("state specific variations", dbOpenSnapshot) Transtype.OpenRecordset = db.OpenRecordset("Trans type", dbOpenSnapshot) T1.OpenRecordset = db.OpenRecordset("Table1", dbOpenSnapshot)
tmpbl.OpenRecordset = db.OpenRecordset("temptbl", dbOpenSnapshot)
stState = cmbState.Text
stTranstype = cmbTrans.Text
Do While Not T1.EOF
qry = "INSERT INTO tmpbl ( [Insert No], [Insert Replaced], [description of communication], [type of transaction], State )" qry = qry & " SELECT T1![Insert No], Replacement![Insert Replaced], T1![description of communication], Transtype!Abbrev, T1!State"
qry = qry & " FROM ((Transtype INNER JOIN T1 ON Transtype!ID = T1![type of transaction]) LEFT JOIN Replacement ON T1![Insert No] = Replacement![Insert Number]) LEFT JOIN SSV ON T1![Insert No] = SSV![state specific form]"
qry = qry & " WHERE (((Transtype!Abbrev) Like "*" & [trans type] & "*") AND ((Table1.State) Like "--" Or (T1.State) Like "*" & [staten] & "*"));
Loop
DoCmd.RunSQL qry
SSV.Close
Transtype.Close
T1.Close
tmpbl.Close
