I have a form where the arrival date is entered then all the info is exported to excel. However I can not seem to spot my error I keep getting query not found or tablename incorrect. Can someone please take a look at my code to see where I am going wrong.
Below is the Code THANKS
Private Sub cmdExport_Click ()
On Error GoTo FinalStep
Dim querystring As String
Dim dbase As DAO.Database
Dim rsSchedules As DAO.Recordset
Dim tempi As Integer
Dim rptcnt As Integer
rptcnt = 0
'validations
If IsNull(txtStart Date.Value) Or Len(Trim(txtSta rtDate.Value)) = 0 Then
MsgBox " Invalid Report Date(s)", vbCritical, "Report Type"
ElseIf Not IsNull(txtStart Date.Value) Or Len(Trim(txtSta rtDate.Value)) = 0 Then
MsgBox "Exporting daily RON flight report for " & CStr(txtStartDa te.Value)
Set dbase = CurrentDb()
Set rsSchedules = dbase.OpenRecor dset(querystrin g)
'not sure why this query or tbl is not being recognized[/b]
querystring = "select * from tblflight1 where # Arrivaldate =#" & txtStartDate.Va lue & "#;)"
'I also tried this code
querystring = "select * from tblflight1 where tblflight1.Arri valdate Between Forms!frmexport adhocron.txtSta rtDate.Value"
DoCmd.RunSQL querystring
If Not (rsSchedules.EO F = True) Then
CreateDailyRepo rt rsSchedules
rptcnt = 1
End If
rsSchedules.Clo se
dbase.Close
If (rptcnt = 0) Then
MsgBox "No Reports Found for Excel Export", vbExclamation, "Export"
Else
MsgBox "Export to excel file(s) completed", vbExclamation, "Export Complete"
End If
Set rsSchedules = Nothing
Set dbase = Nothing
End If
Exit Sub
FinalStep:
MsgBox Err.Description , vbCritical, "Error"
End Sub
I think that my problem lies somewhere here
'not sure why this query or tbl is not being recognized[/b]
querystring = "select * from tblflight1 where # Arrivaldate =#" & txtStartDate.Va lue & "#;)"
'I also tried this code
querystring = "select * from tblflight1 where tblflight1.Arri valdate Between Forms!frmexport adhocron.txtSta rtDate.Value"
1 2262
I have a form where the arrival date is entered then all the info is exported to excel. However I can not seem to spot my error I keep getting query not found or tablename incorrect. Can someone please take a look at my code to see where I am going wrong.
Below is the Code THANKS
Private Sub cmdExport_Click ()
On Error GoTo FinalStep
Dim querystring As String
Dim dbase As DAO.Database
Dim rsSchedules As DAO.Recordset
Dim tempi As Integer
Dim rptcnt As Integer
rptcnt = 0
'validations
If IsNull(txtStart Date.Value) Or Len(Trim(txtSta rtDate.Value)) = 0 Then
MsgBox " Invalid Report Date(s)", vbCritical, "Report Type"
ElseIf Not IsNull(txtStart Date.Value) Or Len(Trim(txtSta rtDate.Value)) = 0 Then
MsgBox "Exporting daily RON flight report for " & CStr(txtStartDa te.Value)
Set dbase = CurrentDb()
Set rsSchedules = dbase.OpenRecor dset(querystrin g)
'not sure why this query or tbl is not being recognized[/b]
querystring = "select * from tblflight1 where # Arrivaldate =#" & txtStartDate.Va lue & "#;)"
'I also tried this code
querystring = "select * from tblflight1 where tblflight1.Arri valdate Between Forms!frmexport adhocron.txtSta rtDate.Value"
DoCmd.RunSQL querystring
If Not (rsSchedules.EO F = True) Then
CreateDailyRepo rt rsSchedules
rptcnt = 1
End If
rsSchedules.Clo se
dbase.Close
If (rptcnt = 0) Then
MsgBox "No Reports Found for Excel Export", vbExclamation, "Export"
Else
MsgBox "Export to excel file(s) completed", vbExclamation, "Export Complete"
End If
Set rsSchedules = Nothing
Set dbase = Nothing
End If
Exit Sub
FinalStep:
MsgBox Err.Description , vbCritical, "Error"
End Sub
I think that my problem lies somewhere here
'not sure why this query or tbl is not being recognized[/b]
querystring = "select * from tblflight1 where # Arrivaldate =#" & txtStartDate.Va lue & "#;)"
'I also tried this code
querystring = "select * from tblflight1 where tblflight1.Arri valdate Between Forms!frmexport adhocron.txtSta rtDate.Value"
give this a go -
Private Sub cmdExport_Click()
-
On Error GoTo FinalStep
-
-
Dim querystring As String
-
Dim dbase As DAO.DataBase
-
Dim rsSchedules As DAO.Recordset
-
Dim tempi As Integer
-
Dim rptcnt As Integer
-
rptcnt = 0
-
-
'validations
-
If Nz(Me.txtStartDate, 0) = 0 Or Len(Trim(Me.txtStartDate)) = 0 Then
-
-
MsgBox " Invalid Report Date(s)", vbCritical, "Report Type"
-
End If 'End of validation
-
MsgBox "Exporting daily RON flight report for " & CStr(txtStartDate.Value)
-
Set rsSchedules = CurrentDb.OpenRecordset(querystring)
-
'not sure why this query or tbl is not being recognized[/b]
-
querystring = "select * from tblflight1 where Arrivaldate = #" & Me.txtStartDate & "#;"
-
'I also tried this code
-
'querystring = "select * from tblflight1 where tblflight1.Arrivaldate Between Forms!frmexportadhocron.txtStartDate.Value"
-
DoCmd.RunSQL querystring
-
If Not (rsSchedules.EOF = True) Then
-
CreateDailyReport rsSchedules
-
rptcnt = 1
-
End If
-
rsSchedules.Close
-
If (rptcnt = 0) Then
-
MsgBox "No Reports Found for Excel Export", vbExclamation, "Export"
-
Else
-
MsgBox "Export to excel file(s) completed", vbExclamation, "Export Complete"
-
End If
-
Set rsSchedules = Nothing
-
Set dbase = Nothing
-
Exit Sub
-
FinalStep:
-
MsgBox err.Description, vbCritical, "Error"
-
End Sub
-
J
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Shane |
last post by:
I have a problem that I have spent an age on and can't resolve.
Basically, I have a table that has a date field. I have created SP's to
return values within a given date range.
The problem that I have is that when I append some data to the table,
inconsistency occurs.
What basically happens is that when I run the SP within SQL Analyser,
the resultset returns correctly, including ALL data between the two date
|
by: Mike Dundee |
last post by:
I am importing data into a new database (the database still has to be
set up) and have a problem. The comma delimited text files I am
importing have four fields containing date and date/times. One field
in particular has a date format of MMM dd yyyy hh:mmAM eg Feb 20 2004
10:00AM. The other fields import correctly (although I haven't run a
query against them) they have two other formats: dd/mm/yy hh:mm:ss and
"plain old" dd-mm-yy. The...
|
by: Nicolae Fieraru |
last post by:
Hi All,
I have a table tblProducts where I have four fields:\
Index, ProductName, EnterDate (as Date/Time - Medium Date), PurchaseDate
(Date/Time - Medium Date)
The EnterDate is automatically filled (with Now()) and the purchase date is
entered manually.
Meantime I became aware that instead of Now() I should use Date() for the
date
|
by: |
last post by:
Source Error:
Line 173: sData(rownumber - 1, lcnt) = WhatCol.Value
Line 174: End IF
Line 175: If (sData(rownumber, lcnt) = sData(rownumber - 1,
lcnt)) AND (WhatCol.Type <> 5 AND WhatCol.Type <> 6) Then
Line 176: If rownumber = 3 Then
Line 177: thisfield = WhatCol.Value
|
by: www.ttdown.com |
last post by:
Each day a user is supposed to import a list of information into a
database table. The user only has 30 days to import this information.
After 30 days the information is lost. I need to be able to create a
form or a report or something that a user would be able to review and
show that a day was missed doing the import (indicating they forgot to
import that days information).
The table the information is being imported into is called...
| |
by: Wes Brooks |
last post by:
Hello expert,
Please help me with the following problems. I have spent ages to resolve
them but no luck.
I have two forms.
(1) "Document Reception Input Form" is the main form. The search field
Document ID is unbound combo box. The table is Documents.
(2) "Document Reception Subform" is the sub form in tabular form. The linked
field is DocID. The table is DocumentReception.
|
by: cjordan |
last post by:
Hi everyone. I'm new here, and I think I've got a pretty unique problem (haven't found any solution to this anywhere else), but I'm hoping that someone here can help me.
To be honest, I'm not a DB2 guy. I'm a contractor working for a client who uses a very old AS400 to do their payroll. They're running V5R3. I'm not sure if that refers to the version of DB2 or the version of the iSeries OS that we're running. Maybe they're the same thing. As...
|
by: osward |
last post by:
Hi everyone,
Background
1. I have a table that consits 400+ rows of data and is growing by day. The table already has paging links at the bottom but I restricted to display rows of data only >= current date. Otherwise, user have to waste time to page up the pages to find the current date
2. I got a script of simple calendar from the web that use mktime() to create links on the calendar
Task
I need to let user view data earlier than...
|
by: nhkam |
last post by:
I am using MS Access 2007
I have a transaction table which holds all records with posting date on each of them. I used a make table query to find out the max date hold in the transaction table and use the dateAdd function to find the date with 1 month, 5 months and 6 months ago and export it into a table name TRSMPD that only have one record.
I then use the TRSMPD table to query the transaction table to find the records that has dates greater...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |