ODBC Connection & auto-login

P

Pendragon

Access03/WinXP

I read the help file on ODBC connections and found a couple of posts
regarding connecting to ODBC tables and programmatically supplying user ID
and password information. I'm still getting the prompt to log in. The
assumption is that the user will not have previously logged in to the
database prior to activating the code below. The code is initiated by a
command button and a call to a public procedure to import data. If I
manually type in the log in info, everything works fine, so I'd just like to
resolve programmatically supplying the user ID and password.

Hovering over the linked table reveals:

ODBC; DNS=PHX_AN; DESCRIPTION=PHX_AN;APP=Microsoft Office 2003; WSID=<<local
computer ID>>; DATABASE=AN_PHX; TABLE=dbo.V_ProductionDetail.

Any information is greatly appreciated.

Dim strFileName As String
Dim StartDate As Date
Dim EndDate As Date
Dim sSQL As String
Dim qryData As QueryDef

sSQL = "DELETE * FROM zTemp_PHX_ProdDetail"
DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True

StartDate = Forms!frmGetData.cboPayrollDate.Column(2)
EndDate = Forms!frmGetData.cboPayrollDate.Column(3)
sSQL = "INSERT INTO zTemp_PHX_ProdDetail ( InvoiceDate, InvoiceID,
InvoiceDetailID, CustomerID, CustomerName, ProductID, ProductDesc,
DollarsShipped, AMRepID, ProdCat, AdjNetShipments, InvoiceType,
SecondaryCategory, PrimaryCategory, Class, Channel, TERepID ) " & _
"SELECT dbo_V_ProductionDetail.InvoiceDate,
dbo_V_ProductionDetail.InvoiceID, dbo_V_ProductionDetail.InvoiceDetailID,
dbo_V_ProductionDetail.CustomerID, dbo_V_ProductionDetail.CustomerName,
dbo_V_ProductionDetail.ProductID, dbo_V_ProductionDetail.ProductDesc,
dbo_V_ProductionDetail.DollarsShipped, dbo_V_ProductionDetail.AMRepID,
dbo_V_ProductionDetail.ProdCat, dbo_V_ProductionDetail.AdjShipments,
dbo_V_ProductionDetail.InvoiceType, dbo_V_ProductionDetail.SecondaryCategory,
dbo_V_ProductionDetail.PrimaryCategory, dbo_V_ProductionDetail.Class,
dbo_V_ProductionDetail.Channel, dbo_V_ProductionDetail.TERepID " & _
"FROM dbo_V_ProductionDetail " & _
"WHERE dbo_V_ProductionDetail.InvoiceDate >= #" & StartDate & "#
AND dbo_V_ProductionDetail.InvoiceDate <= #" & EndDate & "# " & _
"ORDER BY dbo_V_ProductionDetail.InvoiceDate;"

Set qryData = CurrentDb.CreateQueryDef("CS")
qryData.Connect = "ODBC;DATABASE=AN_PHX;UID=RPT001;PASSWORD=CRS1X!0"
qryData.SQL = sSQL

DoCmd.SetWarnings False
DoCmd.RunSQL sSQL
DoCmd.SetWarnings True

CurrentDb.QueryDefs.Delete "CS"

MsgBox "The data set has been successfully imported. Click on OK to
continue.", vbOKOnly


***END***
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top