Report with comboboxes in cell |
Post Reply |
Author | |
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
Posted: 17 January 2008 at 8:53pm |
I am trying to create a report, that has cells which contain a combobox (dropdown list).
The column name should specify the items in the list, so that for example, if we have a report containing the following columns: Column 1: "Sales Man" - permitted values in combo box {Joe, Fred, Barney} Column 2: "Car Sold" - permitted values in combo box {Nissan, Ford, Ferrari} I have see from the Report control documentation, that this should be possible, but I can't figure out how to do it - can someone please post a little VB6 sample code that shows how to do this? |
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
This should get you started.
Set Column = .Columns.Add(COL_EMPLOYEETYPE, "Employee Type", 80, True) Column.EditOptions.AddComboButton Column.EditOptions.ConstraintEdit = True Column.EditOptions.Constraints.Add "Contract", 1 Column.EditOptions.Constraints.Add "Hourly", 2 Column.EditOptions.Constraints.Add "Salary", 3 |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
This code does not work - does anyone else know how to do this? - I am rapidly running out of patience for the so called "support" from CodeJock
|
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
When I say the code d"does not work", I mean it does NOT display a drop down list in the cell when I click on the cell.
Also, the code as it stands, its pretty useless - I had to add a row (none of the sample code in the help file work), and after fiddling with it for hours, realized I had to call the Populate() method on the control (a single line which would have saved hours of rummaging through the pretty useless documentation) AND I still can't the damn code to work. DOES anyone else know how to do this? |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Apologies for all the typos, but I'm getting pretty hot under the collar because of the pretty much non-existent help available for the controls.
|
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
Neil,
This code does work. Why don't you paste your code here and I'll take a look at it. I use combo boxes in reports all the time. |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Apologies if I was a bit curt in my last post - I am getting rather desperate, I had assumed that the code snippet would work and so had waited till the last moment to add it to my application - only to find it did not work, and I have a demo presentation on Monday.
I will make a small demo prog and upload it - hopefully you (or someone) may be able to pinpoint why it does not work |
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
Do it quickly. I'm leaving in a couple of hours for the day but I can take a look at it if you get it here soon.
|
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
I am assuming that you are using vb6 with CJ 11.2.2
That's what I'm using |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Yes, I am using v 11.2
I will put my other work on hold now and do the demo |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
How do I upload the demo file (zip file) ?
Shall I send it to a email address? |
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
send it to jcollier@optitekinc.com
|
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Done - thanks
|
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
I sent the demo to the email address you kindly provided - I hope you can help point out what I may be doing incorrectly
|
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
I got it. I've found the problem. I'm fixing it and will return it shortly.
|
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Thank you
|
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
I sent it back to you. Let me know if you didn't get it.
|
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Just got it now - I was away for a few hours. I'll give you feedback ASAP.
Thanks |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Thanks Jason - it now does EXACTLY what I want it to do.
One last question though, if I may. Do you know how I can restrict the value a user types into the cell of a column (e.g. the 'Age' column), so that only numbers can be typed into that column? MTIA |
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
Try this:
Private Sub wndReport_PreviewKeyDown(KeyCode As Integer, ByVal Shift As Integer, Cancel As Boolean) If (KeyCode < 48 Or KeyCode > 57) And KeyCode <> 8 Then Cancel = True End If End Sub I also noticed an error in the form_load event. Notice the changes with the constants: 'Create the second column Set Column = .Columns.Add(COLUMN_EMPLOYEE_NAME, "Name", DFLT_COL_WIDTH, True) Column.Editable = False 'Create the third column Set Column = .Columns.Add(COLUMN_EMPLOYEE_AGE, "Age", DFLT_COL_WIDTH, True) Column.Editable = True |
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
Ignore the PreviewKeyDown part. It's not right.
|
|
jcollier
Senior Member Joined: 15 February 2006 Status: Offline Points: 250 |
Post Options
Thanks(0)
|
Ok. This is kinda hacked so if someone knows a better way, please let me know.
Add Dim blnNumericOnly As Boolean to General Declaration of the form Private Sub wndReport_MouseDown(Button As Integer, Shift As Integer, x As Long, y As Long) Dim hitItem As ReportRecordItem Set hitItem = wndReport.HitTest(x, y).Item If Not hitItem Is Nothing Then If hitItem.Index = COLUMN_EMPLOYEE_AGE Then blnNumericOnly = True Else blnNumericOnly = False End If End If End Sub Private Sub wndReport_PreviewKeyDown(KeyCode As Integer, ByVal Shift As Integer, Cancel As Boolean) If blnNumericOnly = False Then Exit Sub If (KeyCode < 48 Or KeyCode > 57) And KeyCode <> 8 Then Cancel = True End If End Sub |
|
Neil
Groupie Joined: 16 December 2007 Status: Offline Points: 40 |
Post Options
Thanks(0)
|
Hi Jason, MANY MANY thanks for all of your help so far. I had spotted the bug regarding the Column numbers and had fixed it already. The latest code (although not behaving exactly as I want it to), provides more than enough of a framework for me to extend it to do what I want.
Once again, thank you VERY VERY much, and have a nice weekend. |
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |