Query- use form as parameter box

G

Guest

I have been kindly helped with the following query on here and it works very
well.

SELECT BOOKS.Number, BOOKS.[Number 2], BOOKS.BookDate, BOOKS.Forename,
BOOKS.Surname, BOOKS.Unit, BOOKS.Returned, BOOKS.Archived
FROM BOOKS
WHERE (((BOOKS.Number)=Left([Enter a 7 digit sheet no:],5) &
IIf(Val(Right([Enter a 7 digit sheet no:],2)>50),"51","01")))
ORDER BY BOOKS.Number DESC;

Basically the code prompts for a number and then opens a form based on the
query above.

I am now looking at using a form as the parameter dialogue box so I can
possibly incorporate a mask on the form/parameter box.

I have found the following code which does the job but I need to incorporate
the original code above.

[Forms]![Form1]![textbox1]

textbox1 is the text box where the number is entered on the form/parameter
box and Form1 is the form which I am using as a parameter box.

Many thanks in advance.
 
G

Guest

Try

SELECT BOOKS.Number, BOOKS.[Number 2], BOOKS.BookDate, BOOKS.Forename,
BOOKS.Surname, BOOKS.Unit, BOOKS.Returned, BOOKS.Archived
FROM BOOKS
WHERE (((BOOKS.Number)=Left([Forms]![Form1]![textbox1],5) &
IIf(Val(Right([Forms]![Form1]![textbox1],2)>50),"51","01")))
ORDER BY BOOKS.Number DESC;

Replacing [Enter a 7 digit sheet no:] with [Forms]![Form1]![textbox1]
 
G

Guest

Thanks Ofer

That works great.
--
Richard


Ofer Cohen said:
Try

SELECT BOOKS.Number, BOOKS.[Number 2], BOOKS.BookDate, BOOKS.Forename,
BOOKS.Surname, BOOKS.Unit, BOOKS.Returned, BOOKS.Archived
FROM BOOKS
WHERE (((BOOKS.Number)=Left([Forms]![Form1]![textbox1],5) &
IIf(Val(Right([Forms]![Form1]![textbox1],2)>50),"51","01")))
ORDER BY BOOKS.Number DESC;

Replacing [Enter a 7 digit sheet no:] with [Forms]![Form1]![textbox1]
--
Good Luck
BS"D


Richard said:
I have been kindly helped with the following query on here and it works very
well.

SELECT BOOKS.Number, BOOKS.[Number 2], BOOKS.BookDate, BOOKS.Forename,
BOOKS.Surname, BOOKS.Unit, BOOKS.Returned, BOOKS.Archived
FROM BOOKS
WHERE (((BOOKS.Number)=Left([Enter a 7 digit sheet no:],5) &
IIf(Val(Right([Enter a 7 digit sheet no:],2)>50),"51","01")))
ORDER BY BOOKS.Number DESC;

Basically the code prompts for a number and then opens a form based on the
query above.

I am now looking at using a form as the parameter dialogue box so I can
possibly incorporate a mask on the form/parameter box.

I have found the following code which does the job but I need to incorporate
the original code above.

[Forms]![Form1]![textbox1]

textbox1 is the text box where the number is entered on the form/parameter
box and Form1 is the form which I am using as a parameter box.

Many thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top