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

Check content of ComboBox against Query populating it

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
AConnection
General User
General User


Joined: 08 Oct 2003
Posts: 5

PostPosted: Fri Mar 19, 2004 1:20 pm    Post subject: Check content of ComboBox against Query populating it Reply with quote

Thanks for looking at this. I am trying now to take data entered into a combo box field in a form and check it against the query (or a query) that populates the box. It is very simple to generate a query to populate the box, and I can create a macro to check the content of the field, but how do I get both together? This would be a macro applied upon exiting the field, to emulate Access' ability to restrict the input of a field to the selection list. Thanks.
Back to top
View user's profile Send private message
dfrench
Moderator
Moderator


Joined: 03 Mar 2003
Posts: 1605
Location: Wellington, New Zealand

PostPosted: Fri Mar 19, 2004 2:04 pm    Post subject: Reply with quote

The control combobox has two properties: stringitemlist contains your valid items and text contains the entry (typed or selected from the list). The following code tests whether text is found within stringitemlist.
Code:
Sub Main
'get the combo box control by name
octl= thiscomponent.drawpage.forms.getbyname("Standard").getbyname("ComboBox")
inlist=false
i=0
do while i<=ubound(octl.stringitemlist)
   if octl.text= octl.stringitemlist(i) then
      inlist=true
      exit do
   end if
   i=i+1 ' increment through stringitemlist   
loop
if not inlist then
   msgbox  "Entry not in valid list"
end if   
End Sub
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 Macros and API 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