OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

SOLVED Query SQL code: calling for a parameter input

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
JimNH14
General User
General User


Joined: 12 Dec 2011
Posts: 8
Location: UK

PostPosted: Sun May 13, 2012 9:15 am    Post subject: SOLVED Query SQL code: calling for a parameter input Reply with quote

I need to set up a query so that when it is run the user is asked for the value of a parameter - for example an ID number which is held in the relevant table, then run the query with that variable specified.

The excellent Base Tutorial by Mariano Casanova suggests eg:
WHERE "ID"=:ID number
but this does not seem to work

How is it done?


Last edited by JimNH14 on Sun May 13, 2012 2:09 pm; edited 1 time in total
Back to top
View user's profile Send private message
Sliderule
Super User
Super User


Joined: 29 May 2004
Posts: 2473
Location: 3rd Rock From The Sun

PostPosted: Sun May 13, 2012 9:27 am    Post subject: Reply with quote

When using a prompt query ( also referred to as a Parameter Query Smile ), so the user is asked to enter a value, or, values . . . the prompt starts with a colon ( : ) and, must be one word ( no spaces ).

Therefore, I like to use an underscore ( _ ) to simulate a space in the display. This makes it easier for the user to understand.

In your example, change it to. either of the following ( your choice ) Smile :

Code:
WHERE "ID" = :ID_number

WHERE "ID" = :Enter_ID_number

I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your first post Title ( edit button ) if your issue has been fixed / resolved.
Back to top
View user's profile Send private message
JimNH14
General User
General User


Joined: 12 Dec 2011
Posts: 8
Location: UK

PostPosted: Sun May 13, 2012 11:07 am    Post subject: Reply with quote

Thanks for this - I have tried it and it no longer rejects the code or gives error messages but there is no dialogue box and the output has headings but no data.

Sad
Back to top
View user's profile Send private message
JimNH14
General User
General User


Joined: 12 Dec 2011
Posts: 8
Location: UK

PostPosted: Sun May 13, 2012 12:35 pm    Post subject: Query SQL code: calling for a parameter input Reply with quote

Thanks for this - I have tried it and it no longer rejects the code or gives error messages but there is no dialogue box and the output has headings but no data.

This is in response to Sliderule's suggestion below:
When using a prompt query ( also referred to as a Parameter Query ), so the user is asked to enter a value, or, values . . . the prompt starts with a colon ( : ) and, must be one word ( no spaces ).

Therefore, I like to use an underscore ( _ ) to simulate a space in the display. This makes it easier for the user to understand.

In your example, change it to. either of the following ( your choice ) :
Code:
WHERE "ID" = :ID_number

WHERE "ID" = :Enter_ID_number


I hope this helps, please be sure to let me / us know.

Sliderule
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group