473,673 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

my query doesnt work

DL
Hi,
I'm using this query in VBA:
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid='"& CurrentUser() & "' "

im using it like this:
Set dbs = CurrentDb
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid= '" & CurrentUser() & "'"
Set Some_Recordset = dbs.OpenRecords et(SQL_Str)

But i'm getting no records?

I know there are records to show.

Can anybody help me???
I've already spent two hours+ looking on this one...
Nov 13 '05 #1
4 1552
Since you're delimiting Forms!TijdReg.[datumveld] with #, I assume datum is
a date field. What's the content of Forms!TijdReg.[datumveld]? Regardless of
what you've set the short date format to in your Regional Settings, it must
be in mm/dd/yyyy format (or else an unambiguous format such as dd mmm yyyy
or yyyy-mm-dd)
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"DL" <da*******@hotm ail.com> wrote in message
news:40******** *************@n ews.wanadoo.nl. ..
Hi,
I'm using this query in VBA:
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid='"& CurrentUser() & "' "

im using it like this:
Set dbs = CurrentDb
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid= '" & CurrentUser() & "'"
Set Some_Recordset = dbs.OpenRecords et(SQL_Str)

But i'm getting no records?

I know there are records to show.

Can anybody help me???
I've already spent two hours+ looking on this one...

Nov 13 '05 #2
"DL" <da*******@hotm ail.com> wrote in message news:<40******* **************@ news.wanadoo.nl >...
Hi,
I'm using this query in VBA:
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid='"& CurrentUser() & "' "

im using it like this:
Set dbs = CurrentDb
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid= '" & CurrentUser() & "'"
Set Some_Recordset = dbs.OpenRecords et(SQL_Str)

But i'm getting no records?

I know there are records to show.

Can anybody help me???
I've already spent two hours+ looking on this one...


If pid is a Long rather than text you don't use the single quotes:
Forms!TijdReg.[datumveld] & "# AND pid= " & CurrentUser() & ";"

Access doesn't automatically convert names into key fields so if
CurrentUser() returns a text field you have to retrieve the pid using
a JOIN in your SQL statement or some other method like a lookup
function.

James A. Fortune
Nov 13 '05 #3
Hi Daantje,

I presume you're from Holland or somewhere near, so the problem will
probably be the date format, wich is dd/mm/yyyy in dutch and
mm/dd/yyyy in the Access database. To correct this use the Format()
function:
SQL_Str = SQL_Str = "SELECT pid FROM registratie WHERE datum =#" &

Format(Forms!Ti jdReg.[datumveld],"mm/dd/yyyy")

& "# AND pid='"& CurrentUser() & "' "

(All on one line, i just cut out the relevant part for illustration)
That should work just fine.

Good luck,

Gert-Jan


"DL" <da*******@hotm ail.com> wrote in message news:<40******* **************@ news.wanadoo.nl >...
Hi,
I'm using this query in VBA:
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid='"& CurrentUser() & "' "

im using it like this:
Set dbs = CurrentDb
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid= '" & CurrentUser() & "'"
Set Some_Recordset = dbs.OpenRecords et(SQL_Str)

But i'm getting no records?

I know there are records to show.

Can anybody help me???
I've already spent two hours+ looking on this one...

Nov 13 '05 #4
DL,
CurrentUser should return a string representing the currently logged in user
in Access' security model. It is often Admin if security is not enabled.
Check & see what CurrentUser is returning to your code and make sure it is
what was intended. I'd bet you are getting a value that doesn't match what
you expected it to be and thus won't get any records back.

"DL" <da*******@hotm ail.com> wrote in message
news:40******** *************@n ews.wanadoo.nl. ..
Hi,
I'm using this query in VBA:
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid='"& CurrentUser() & "' "

im using it like this:
Set dbs = CurrentDb
SQL_Str = "SELECT pid FROM registratie WHERE datum=#" &
Forms!TijdReg.[datumveld] & "# AND pid= '" & CurrentUser() & "'"
Set Some_Recordset = dbs.OpenRecords et(SQL_Str)

But i'm getting no records?

I know there are records to show.

Can anybody help me???
I've already spent two hours+ looking on this one...

Nov 13 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1866
by: rob21century | last post by:
Hello i will be a web designer one day but until then i need a little help I have a search query that searches the database for user entered string. See below: $query = "SELECT * From MyTable WHERE Company_Name LIKE \"%$postrimmedcompname%\" ORDER BY Company_Name" ; This works fine. If I enter "estate agents", I get the results. and also if I enter "estate" or I enter "agents" I also get the results. However, if I enter "estate...
5
1369
by: orfiyus | last post by:
Hi I am having a problem with a query. I am trying to query my oracle database for a certain number corresponding to at least 4 other fields of information. Anyway I dont know what is going on but the query doesnt work unless I pull out the part of the clause which contains a string. All other where clauses contain integers stored into php variables but for some reason it doesnt like the string. I would appreciate if someone could take a...
0
4312
by: padmaneha | last post by:
Hi Thanks for your response but the query which you gave in my previous post doesnt work. It displays the same cnt for movie reviews and videoreviews Let me explain you in detail As I said I have got two tables like one is 'Food table' and the other one is the 'Videos' table Columns which I have created in 'Food' table are 'foodid' and 'blogcid' colcumns which I have created in Videos table are 'videoid, 'destid', 'videotitle'
3
5532
by: rinu911 | last post by:
hi all I am tring to insert a values to a table by checking if the value is there in the table already but it gives me this error "Query input must contain at least one table or query" here is my query
5
1559
by: leelotis | last post by:
Hi im doing the following query SELECT * FROM networkinfo JOIN tblimage WHERE networkinfo.network LIKE '$data' && networkinfo.network = tblimage.imgdata && networkinfo.category = '$category' so I can get it to work untill I add the last && networkinfo.category = '$category' this kills the whole query what am I doing wrong? I think it has to do with using the like and where in the same query because I havnt run into this issue before...
0
8508
marktang
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...
0
8428
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8953
Oralloy
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...
0
8854
jinu1996
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...
0
7484
agi2029
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...
0
4253
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...
1
2849
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
2
2104
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.