Hi Albert,
Unfortunately, you can’t directly populate a popupmenu from a column in a table. What you can do however is populate an array with the values you want and then use that array to populate the popupmenu. Something like the below will work for a column of character type (just change the array and strSelection variables to the appropriate type if your column is not a character type):
Include "MapBasic.def"
Declare Sub Main
Sub Main
Dim strValues() as String '// Dim your array
Dim i as Integer '// Array counter
Dim iSelection as Integer '// Index of selection from popupmenu
Dim strSelection as String '// String variable to store selected value
Select yourColumn from yourTable Group By yourColumn into UniqueList '// Select unique values of yourColumn into table UniqueList
If TableInfo(UniqueList, TAB_INFO_NROWS) > 0 then '// Check that selection returned more than 0 rows
Redim strValues(TableInfo(UniqueList, TAB_INFO_NROWS)) '// Resize the array to the number of returned rows
i = 0
'// Populate array with unique values
Do while Not EOT(UniqueList)
i = i + 1
strValues(i) = UniqueList.yourColumn
Loop
End If
Dialog
Title "A Dialog Box"
Control PopUpMenu
Position 4, 10
Width 80
Title From Variable strValues() '// Use array to populate values in popupmenu
Into iSelection '// Store index of selected value into iSelection when ok button is clicked
Control OkButton
Position 10, 28
If CommandInfo(CMD_INFO_DLG_OK) then '// Check that the OK button was clicked in dialog box
strSelection = strValues(iSelection) '// Get selected value from array
End If
End Sub
Hope this helps,
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups
"MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Mouchel Limited (Mouchel) is registered in England and Wales with registered number 01686040 at Export House, Cawsey Way, Woking, Surrey, UK, GU21 6QX. The information in this e-mail is confidential and may be legally privileged. It is intended solely for the addressee. Access to this email by anyone else is unauthorised. Any views or opinions expressed in this e-mail may be solely those of the author and are not necessarily those of Mouchel. No contracts may be concluded on behalf of Mouchel by means of email communications. Mouchel reserves the right to monitor and intercept emails sent and received on our network. |
Do while Not EOT(UniqueList)
i = i + 1
strValues(i) = UniqueList.yourColumn
Loop
Indeed it should! Time for a coffee I think…
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups
"MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
Does a Do...Loop have an advantage over a For...Next here? I would write it like this:
According to this: http://bytes.com/topic/access/insights/797078-next-vs-do-loop-winner
… For… Next is the winner by about 50%. I tend to chop and change between the two with no particular thoughts about why, just whatever I happen to use at the time. I think I might stick with For… Next in most cases from now on!
Tom Bacon
GIS Engineer, Mouchel
T 01444 472380 │ E thomas...@mouchel.com │ W www.mouchel.com
Our values: innovation │ excellence │ integrity │ responsibility
From: mapi...@googlegroups.com [mailto:mapi...@googlegroups.com] On Behalf Of DMcE
Sent: 07 August 2013 09:58
To: mapi...@googlegroups.com
--
--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en
---
You received this message because you are subscribed to the Google Groups
"MapInfo-L" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to mapinfo-l+...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.