This is really strange if I put both procedures in the same vb code event, then it works.
Private Sub Command3_Click()
Dim db As DAO.Database
Dim qd As DAO.QueryDef
Dim q1 As DAO.QueryDef
Dim q2 As DAO.QueryDef
Dim q3 As DAO.QueryDef
Dim q4 As DAO.QueryDef
Dim q5 As DAO.QueryDef
Dim ve As DAO.QueryDef
Set db = CurrentDb
Set qd = db.QueryDefs("ZDOR_ITM")
Set q1 = db.QueryDefs("BOF_CURR")
Set q2 = db.QueryDefs("DUE_CURR")
Set q3 = db.QueryDefs("ZDOR_ACF")
Set q4 = db.QueryDefs("STK_BUY")
Set q5 = db.QueryDefs("ZDOR_WSP")
Set ve = db.QueryDefs("VEtrack")
DoCmd.SetWarnings False
ve.SQL = "SELECT * FROM VETRACK.PROJECT@dscr_css " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
q5.SQL = "SELECT * FROM DSS_USER.V_Portal_ZDOR_WSP " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
DoCmd.OpenQuery "Get_WSP_INfo"
qd.SQL = "SELECT * FROM DSS_USER.V_Portal_ZDOR_ITM " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
DoCmd.OpenQuery "Get_ITM (MM data)"
q1.SQL = "SELECT * FROM DSS_USER.V_Portal_ZDOR_BOF_CURR " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
DoCmd.OpenQuery "Get_BO"
q2.SQL = "SELECT * FROM DSS_USER.V_Portal_ZDOR_DUE_CURR " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
DoCmd.OpenQuery "Get_Due_Curr"
q3.SQL = "SELECT * FROM DSS_USER.V_Portal_ZDOR_ACF " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
DoCmd.OpenQuery "Get_Purch_Info"
q4.SQL = "SELECT * FROM DSS_USER.STK_BUY_HIST " & _
"WHERE NIIN IN ('" & _
Me.NIIN & "')"
DoCmd.OpenQuery "Get_Purch_Info_Samms"
DoCmd.SetWarnings False
DoCmd.OpenReport "Data Mining Report", AcView.acViewPreview
DoCmd.SetWarnings True
End Sub
But if they are in seperate event commands on the same form I get the cant find odbc table weird huh. The ve.sql is the one that is seperated and needs to be because it is different data. So now I have it all on one commands click.
The problem with that is if a user clicks the other command it gives me the value of the last niin and not the newly queried one. Also it would be nice to have this on the forms open but that would take to long because the one query(not the ve one but everything else) takes a few minutes to get the data(lotta stuff) This is a problem becuase the form also has commands to link to outside web pages with the NIIN's information. Any suggestions?