String Value from DropListbox

3 posts / 0 new
Last post
Pawelski_33
Offline
Joined: 06/05/2018 - 12:16
String Value from DropListbox

Hi there,
I have declared array elements as result of the choice made by the user within 13 DropListBoxes
        UserChoice(0)= ListOfColumns(dlg.DropListBox1) 'Ref
        UserChoice(1)= ListOfColumns(dlg.DropListBox2) 'Value
UserChoice(2)= ListOfColumns(dlg.DropListBox3) 'Dr
         ...  and so on.
 How can I make sure the string value from each of the DropListBox is correctly displayed in tasks  such as :
 - TableManagement and NewField creation - within field.Equation
   My formula in that equation is  = month(value from the DropListBox)  and i have it  as          
   Month(ListofColumns(dlg.DropListBox5) but it doesnt seem to be working.
- database.Gaps - within task.FieldToUse 
  I have currently ListOfColumns(dlg.DropListBox1) in the  function as per below (but it doesnt seem to    be working):
     Function GapDetection(MasterDb,UserChoice() As String)
'Set db = dbhome   
         Set task = MasterDb.Gaps
task.FieldToUse =  ListOfColumns(dlg.DropListBox1)  
MsgBox ListOfColumns(dlg.DropListBox1) 
task.UseCutoffs = False
task.Increment = 1
dbName =  "JE Ref Gap Detection.IMD"                   
task.OutputDBName = dbName
task.PerformTask
Set task = Nothing
Set MasterDb = Nothing
Client.OpenDatabase (dbName)
End Functiion

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Pawelski_33,

Just a few things.  Instead of using the dlg.DropListBox1 as part of your equation use the UserChoice() as this is the variable that is holding the name of the field.

If the equation is for the equation editor it has to use the functions within the equation editor so change your formulat to - "@Month(" & UserChoice(5) & ")"  - this assumes that UserChoice(5) holds the date field.  What you migth want to do for the dialog is instead of showing all fields to use a different list that only holds date fields or numeric fields so you know the user has selected the correct type of field.

Hopefully this helps a bit.

Brian

Pawelski_33
Offline
Joined: 06/05/2018 - 12:16

Thank you Brian, 
Using the formula which you suggested does the trick.
I will follow your suggestion regarding limiting the number of strings(field names) available to chose from in UserChoice(5) to date format field.