473,513 Members | 2,469 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.OpenRecordset(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 1542
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*******@hotmail.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.OpenRecordset(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*******@hotmail.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.OpenRecordset(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!TijdReg.[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*******@hotmail.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.OpenRecordset(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*******@hotmail.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.OpenRecordset(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
1862
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...
5
1361
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...
0
4309
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'...
3
5524
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
1553
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...
0
7269
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...
0
7177
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...
1
7123
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...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4756
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3248
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...
0
1611
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
1
811
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
470
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...

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.