I have a database in ms.access,
I want to retrieve data in the database is based on today's date. I have a query like this.
but when I run this program, it is error.
'Variable not defined' - QuerySelect = "SELECT a.DN, b.DIN, c.PIN, c.UserName, b.Clock, d.ItemName " & _
-
"FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN=b.DN) " & _
-
"LEFT JOIN ras_Users c ON b.DIN=c.DIN) " & _
-
"LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId " & _
-
"WHERE b.DIN=c.DIN AND '" & Format(b > *error,block area.Clock, "mm/dd/yyyy") & "'='" & _
-
Format(um_TglDanJamSkrg, "mm/dd/yyyy") & "'"
-
Set rsDataRAS = da_GetRs(QuerySelect)
Can anyone hel me to fix this error
Regards,
Octo
9 2242
OK, firstly dates have to be enclosed with # marks rather than single quotes. So try this .. -
QuerySelect = "SELECT a.DN, b.DIN, c.PIN, c.UserName, b.Clock, d.ItemName " & _
-
"FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN=b.DN) " & _
-
"LEFT JOIN ras_Users c ON b.DIN=c.DIN) " & _
-
"LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId " & _
-
"WHERE b.DIN=c.DIN AND #" & Format(b > *error,block area.Clock, "mm/dd/yyyy") & "#=#" & _
-
Format(um_TglDanJamSkrg, "mm/dd/yyyy") & "#"
-
Set rsDataRAS = da_GetRs(QuerySelect)
-
If that doesn't work then my guess is we need to look at these two values. - Format(b > *error,block area.Clock, "mm/dd/yyyy")
and - Format(um_TglDanJamSkrg, "mm/dd/yyyy")
We'll need more information on where these values are coming from.
Mary
Dear Mary
thanks for the replies .. but it's still compile error: variable not defined and the same position on 'b.Clock at WHERE ..
#" & Format(b.Clock, "mm/dd/yyyy") & "#=#" & _
Format(um_TglDanJamSkrg, "mm/dd/yyyy") & "#"
Regards,
Octo
- Format(b.Clock, "mm/dd/yyyy")
b.Clock from field in database ms.access table ras_AttRecord b field: Clock - Format(um_TgldanJamSkrg, "mm/dd/yyyy")
um_TgldanJamSkrg from definition of function - Public Function um_TgldanJamSkrg() As Date
-
Dim rsJam As New Recordset
-
Dim strSQL As String
-
-
strSQL = "SELECT GETDATE() AS jam"
-
Set rsJam = da_GetRecord(strSQL)
-
-
um_TgldanJamSkrg = rsJam!jam
-
-
rsJam.Close
-
Set rsJam = Nothing
-
-
End Function
You can't call a function just by inserting the function name in your code. Try this... -
Dim tmpDate As Date
-
-
tmpDate = um_TglDanJamSkrg()
-
-
QuerySelect = "SELECT a.DN, b.DIN, c.PIN, c.UserName, b.Clock, d.ItemName " & _
-
"FROM ((ras_Device a INNER JOIN ras_AttRecord b ON a.DN=b.DN) " & _
-
"LEFT JOIN ras_Users c ON b.DIN=c.DIN) " & _
-
"LEFT JOIN ras_AttTypeItem d ON b.AttTypeId=d.ItemId " & _
-
"WHERE b.DIN=c.DIN AND Format(b.Clock, 'mm/dd/yyyy')=#" & _
-
Format(tmpDate, "mm/dd/yyyy") & "#"
-
Set rsDataRAS = da_GetRs(QuerySelect)
-
Dear Mary,
Many Thanx, but now.. Run-time error
Either BOF or EOF is True, or the current record has been deleted. Requested operation requires a current record.
that caused the data is not available, right?
Regards,
Octo
It sounds like either your function or your query is not returning any records.
Add Debug.Print QuerySelect just before the Set rsDataRAS = da_GetRs(QuerySelect) line. This will print out the query in the "Immediate" window. If you can't tell visually what the problem is then copy and paste the query into a new query and try running it.
Dear Mary,
I've added Debug.Print QuerySelect before Set rsDataRAS = da_GetRs(QuerySelect) line and then I copy and paste the query in the Form_Load, there is no issue, then the desired data are not artifacts in the database, right?
Regards,
Octo
then I copy and paste the query in the Form_Load
I don't understand what you mean by this. I meant for you to create a new query in query design. Change the layout to sql and paste in the query. Then run it and see what the results are.
then the desired data are not artifacts in the database, right?
Not sure what you mean by this.
Dear Mary,
I have try & that's work, Thanks so much for your help..
GBU
Regards,
Octo
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Thomas Mlynarczyk |
last post by:
Hello,
Is there a way to access a static variable defined inside a function from
outside that function? Something like the following:
function foo() {
static $bar = 'stuff';
// more code
}
|
by: lkrubner |
last post by:
An old friend of mine recently approached me and said something like:
"I've a computer at my office that has an Access database running on
it. We've most of our company info in there. We'd like to...
|
by: Atreju |
last post by:
I apologize in advance for the x-post, but I am really not sure where
this would best be addressed.
I am designing a database in MSAccess for which I want to make the
front-end in VB.
I have...
|
by: kai |
last post by:
Hi, All
I try to block some one import my Access database tables using Access
database.
I used password protection, but if some one crack through my password, are
there any other methods to...
|
by: carl.manaster |
last post by:
I'm new to this game. I can find my way around C# without any trouble,
and I've used Access, a little bit, in the past. Now a friend wants an
application of mine to read from his Access database....
|
by: jeet_sen |
last post by:
Hi,
My external javascript test.js contains a variable definition var a =
"Hello,world!!";
I dynamically loaded the script test.js using the following fucntion:
function loadScript(url)
{
var...
|
by: Stephen E. Weber |
last post by:
I have an access database with an "item number" and a filespec for a JPG
with the image for the item and a filespec for a HTM document with the
description and specifications. I use a List Box and...
|
by: bgreer5050 |
last post by:
Where and how do I declare a variable that I want to use throughout
the entire Access database?
Thanks
|
by: =?Utf-8?B?ZG1idXNv?= |
last post by:
I have an Access database with a table named 'tblMedia'. In tblMedia I have a
field named 'Media' that is defined as an 'OLE Ojbect' field. In this Media
field, I have pictures, they are jpegs. I'm...
|
by: Killer42 |
last post by:
Hi all.
I have an application that I wrote ages ago - last compiled in 1998, I believe. It is still in occasional use. It uses an Access database - probably Access version 2, I think.
I...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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...
|
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,...
| |