In a combo control, I’m loading the values using Prop:Sql as below. In combo, values are getting loaded. But I’m unable to change the value in the combo. It stick with the default value. The selected value not showing in the combo control. Below are the screenshots. Is there any command need to add in the procedure?
employees_view - MSSQL File driver
LOC:EmpName_New - Queue file
Emp_Name_New - Field name
If you’re trying to fetch a record from a queue based on a field’s value, you have to utilize the correct syntax for GET(Q).
Try priming the value like so:
CLEAR(LOC:EmpName_New)
LOC:EmpName_New.EmpName_New = Que_new:Emp_Name_New
GET(LOC:EmpName_New,LOC:EmpName_New.EmpName_New)
IF ERRORCODE()
!Respond to an error
ELSE
!Respond to success
END
It would help to see your how your COMBO control is coded? I would guess like below? It is important for us to know what USE() variable is being filled in, and FROM() what Queue.
Your code is confusing to me, I think it probably all wrong. A COMBO is a special form of ENTRY control with a FROM() List that the user can pick a value to be filled in. You typically do not do a GET(Q) when that is Accepted. Maybe you want just a LIST,DROP?
Edit:
Example of a Combo used for a Name Suffix/Prefix to let user pick common choices like JR SR, but they can enter anything they want. The FROM() is a ‘String’ but could be a Queue. The USE() is the data field that gets the data. So a Combo works as an ENTRY with the From choices helping the user quickly pick common choices.
I have another application where the data is submitted to a government agency. They only allow specific values (e.g. JR SR II III IV) or the record will be rejected. In that case I would not use a COMBO, I use a LIST,DROP so the user can only pick the From() values I provide.
I’m sort of with Carl on this.
Unless you can enter something other than your employee list, using a combo as a selector can cause problems because it will allow just anything to be typed.
I can see nothing there that the standard FileDrop control template can’t handle without the mucking about.
I think the only advice you’ve taken so far is to create a view on the server. Now go the whole way: use that view as the “file” source for a Control template (not plain-Jane toolbox) combo box. It will ask for an update procedure. You give it a procedure that will update employee_view, if the view is updateable, or an update procedure that will update the “main” file (i.e. the one with the employee name) if not. Since it’s an Insert you don’t need to worry about priming it from the view fields. The template will also take care of creating your queue for you with the columns you say you want from the view.
Have a look at the code created (plus the FileDropCombo class in FileDrop.clw). Also just think about what the combo box is supposed to do when you start typing into it: it needs to navigate you through the existing list and only if you type something that is not in the list does it need to ask you whether you really want to add a new entry.
What does your code do? On Accepted it reloads the queue from the file. Does it do anything with the value that the user typed, and which should be in a USE variable? Doesn’t look like it.
To explain a bit more: when you add a ComboBox from the toolbox the only thing you get is a Combo Control added to your Window. That’s it.
When you add a FileDropCombo control template it creates the view and queue for the control, in the WindowManager.Init it loads data into the queue plus some other things you don’t have to worry about right now, and attaches your control to a FileDropCombo class.
And importantly, in the WM’s TakeAccepted it adds:
OF ?DCT2:DNAME !That's my combo control
FDCB3.TakeAccepted() !That's a call to a comboxclass method
That method, which you can find in ABdrops.clw looks like below. The comments added are mine, and may not be 100% accurate. The point I’m trying to make is that you are trying to reinvent the wheel, and doing it badly. There probably are a few cases where you might need to have a manually filled and maintained combo box, but until you are absolutely certain that’s what you need, you should probably go with the standard behaviour.
FileDropComboClass.TakeAccepted PROCEDURE()
Qm LONG,AUTO
CODE
? ASSERT(EVENT()=EVENT:Accepted)
IF FIELD()=SELF.EntryField AND ~0{PROP:AcceptAll} ! make sure is the entry field and window is not in acceptall
SELF.UseField = SELF.EntryField{PROP:ScreenText} ! get the value the user typed in
Qm = SELF.GetQueueMatch(SELF.UseField) !Does it match anything already in the queue?
IF Qm <> 0 !Yes it matched, so nothing to add
IF NOT SELF.UseField
Qm = 0
END
ELSE !No it didn't match
IF SELF.Ask() <> Level:Benign !Call the specified update procedure, if it returns Unsuccesssfully
SELF.ResetFromItem(0) !reset the combo box
SELF.UpdateFields.AssignRightToLeft !copy the file items into the queue again
SELECT(SELF.EntryField)
CHANGE(SELF.EntryField,'') !blank the manual entry field
RETURN
END
SELF.UpdateFields.AssignLeftToRight
SELF.ResetQueue(1) !In any case force a refresh of the queue
Qm = SELF.GetQueueMatch(SELF.UseField) !Get the row of the insertred item
END
SELF.ListField{PROP:Selected}=Qm !Set the selected record to the new insert
SELF.ResetFromList !And make sure that record is visible
END