Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
paddybear
Starting Member
1 Post |
Posted - 2012-01-05 : 21:18:28
|
I am a newbie in Ms Access, i need help to solve this problem.I am creating a database to store the customer info, then now, i need to create a report which allow me to printout the data created on certain date. Before that, i need to select some fields from my master table and stored into a temp table. However, i am having problem in date format when i write the SQL code.I stored the create date in medium date (dd-mmm-yyyy).Then I have a form which allow me to keyin the report start date and report end date (dd-mmm-yyyy). But the date show as (dd/mm/yyyy). Can someone please help me to check on the code on below? TQ!Private Sub runReport() Dim rs1 As DAO.Recordset Dim sqlSelectGL1 As String Dim sqlInsert As String Dim startDate As String Dim endDate As String Dim Branch1 As String Dim UserName As String Dim AgentName As String Dim DateCreate As String endDate = Format(CDate(txtEnd), "dd-mmm-yy") startDate = Format(CDate(txtBegin), "dd-mmm-yy") MsgBox endDate sqlSelectGL1 = "SELECT Branch, UserName, IntermediaryName, CreateDate FROM tblMaster WHERE CreateDate >= '" & startDate & "' and CreateDate <= '" & endDate & "'" Set rs1 = CurrentDb.OpenRecordset(sqlSelectGL1) Do While Not rs1.EOF Branch1 = rs1("Branch") UserName = rs1("UserName") AgentName = rs1("IntermediaryName") DateCreate = rs1("CreateDate") sqlInsert = "INSERT INTO tblISOReport (Branch, Type, UserName, AgentName, Status, DateReceive, DateRaise, DateCreate, DateDespatch, User)" & _ "VALUES ('" & Branch1 & "', 'GL', '" & UserName & "', '" & AgentName & "', 'N', ' ', '" & DateCreate & "','" & DateCreate & "','" & DateCreate & "', 'I')" DoCmd.RunSQL sqlInsert rs1.MoveNext Loop rs1.Close End Sub |
|
|
|
|
|
|