Date Format problem

B

Bonnie

Hi there. Using A02 on XP. Got some help on pulling data from tables named
like a field on my form and the query gets changed dynamically each time to
use the 2 tables represented. I need my dates to export as xx/xx/xxxx and 1
works but 2 are still giving me xx/xx/xxxx 0:00. Don't want the time, just
the date. I'm sure it's a formatting typo on my part but can't find it. My
code is:

Private Sub ExpRelius_Click()
Dim strSQL As String
Dim dbsCurrent As Database
Dim qryTest As QueryDef

Set dbsCurrent = CurrentDb

strSQL = "SELECT "

strSQL = strSQL & "IIf((" & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised![SSN])= '000000000', "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy![SSN], "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised![SSN]) AS Social, "

strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.FName, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.LName, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.Gender, "
strSQL = strSQL & "Format(" & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.DOB, ""mm/dd/yyyy"") as BirthDate,"
strSQL = strSQL & "Format(" & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.DOH, ""mm/dd/yyyy"") as HireDate,"
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.Hours, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Revised.Comp, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.DefAmt, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.ExclComp, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.Sec125, "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.StatusCode, "
strSQL = strSQL & "Format(" & [Forms]![fCensus1Conversion]![RunThisOne] &
"Revised.StatusDate, ""mm/dd/yyyy"") AS DateStatus "

strSQL = strSQL & " FROM "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy RIGHT
Join "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Revised ON "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Copy.ID = "
strSQL = strSQL & [Forms]![fCensus1Conversion]![RunThisOne] & "Revised.ID "
strSQL = strSQL & "WITH OWNERACCESS OPTION;"

MsgBox strSQL
Debug.Print strSQL

'the name of your query goes in here
Set qryTest = dbsCurrent.QueryDefs("qCensus1ExportRevised")

qryTest.SQL = strSQL
'Debug.Print strSQL
'other code

Set dbsCurrent = Nothing
Set qryTest = Nothing
'--------------------------------

'Uncomment the MsgBox line or add a Debug.Print strSQL line.
'Debug.Print strSQL
'It should give you the correct SQL for the value selected in the
"RunThisOne" combo box.

'Export the data
DoCmd.RunMacro ("mCensus1.ExportRevised")
MsgBox "Data has been exported to the S:\RPS\PTS\CensusConversion\ToRelius
folder and named " & Me.RunThisOne & ".csv."

End Sub

StatusDate is working well as 01/01/2005 but DOB and DOH still give me
01/01/2005 0:00. It must be my quotes or commas. I mess them up easily.

Any suggestions? Thanks in advance for any help or advice.
 

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

Similar Threads

Permissions on SQL 2
Need date format in strSQL 19
Code chgs table in query 1
Transfer spreadsheet error 4
Mail Merge into MS Word 1
Query Records in Linked table 4
Runtime Error 3079 2
Storing a date in UK format 17

Top