Re: Drop down list in form
Andrew Jensen <[email protected]>
| Newsgroups | gmane.comp.openoffice.dba.user |
|---|---|
| Message-ID | <[email protected]> |
Ok, I created a table named contacts and one named cities. Then a form
named contacts.
The contacts table has a field named 'city' and on the form I put a
combo box that lists
the recrods from the cities table and writes the value to contacts.city.
You know before I write this next line I have to say, the use of the
word form is damned confusing here.
In the database 'form' contacts (this is a writer document) is the
'form' MainForm (this is the embedded rowset object), on this MainForm
in the event "After record change" i call this macro
Sub UpadteCities
dim oConn as Object
dim oStmt as Object
dim ORows as Object
dim cMainForm as Object
oMainForm = thisComponent.Drawpage.forms.getByName( "MainForm" )
oConn = oMainForm.ActiveConnection
oStmt = oConn.CreateStatement
' Check if the text in the city combo box is already in the
cities table
oRows = oStmt.ExecuteQuery( "select * from ""cities"" where ""city""
= " _
+ "'" + oMainForm.ComboBox1.text + "'")
oRows.next
if oRows.Row = 0 then
' if it is not in the cities table
' add it
oStmt.ExecuteUpdate( "insert into ""cities"" Values( " _
+ "'" + oMainForm.ComboBox1.text + "')")
endif
End Sub
Now, this is just a start..and I am sorry it is more then 4 lines
long...but it should show you everthing you need. (oh the idea about the
button before...what can I say...wrong)
HTH
Andrew
[email protected] wrote:
>On 9 Aug 2005 at 20:45, Andrew Jensen wrote:
>
>
>
>>If I can help let me know. I would be happy to setup a small test
>>form and check it out.
>>
>>
>
>That's very generous, I would appreciate that. It seems that over
>the years a macro library for Base will emerge. The small things
>like - opening forms from a button - are a great help to novice
>users. I was actually looking for that sort of library thinking that
>I could solve this by hunting through some examples of macros.
>
>BTW I am not averse to "learning a little OOo Basic" it would no
>doubt be useful. Is there a web-based resource that you would
>recommend as a primer for a "regular" person?
>
>Thanks
>
>Gary
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [email protected]
>For additional commands, e-mail: [email protected]
>
>
>
>
>
>