Report with comboboxes in cell
Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=9340
Printed Date: 24 November 2024 at 1:07pm Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com
Topic: Report with comboboxes in cell
Posted By: Neil
Subject: Report with comboboxes in cell
Date 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?
|
Replies:
Posted By: jcollier
Date Posted: 22 January 2008 at 9:49am
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
|
Posted By: Neil
Date Posted: 28 February 2008 at 9:11pm
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
|
Posted By: Neil
Date Posted: 28 February 2008 at 9:14pm
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?
|
Posted By: Neil
Date Posted: 28 February 2008 at 9:15pm
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.
|
Posted By: jcollier
Date Posted: 29 February 2008 at 9:18am
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.
|
Posted By: Neil
Date Posted: 29 February 2008 at 11:08am
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
|
Posted By: jcollier
Date Posted: 29 February 2008 at 11:36am
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.
|
Posted By: jcollier
Date Posted: 29 February 2008 at 11:37am
I am assuming that you are using vb6 with CJ 11.2.2
That's what I'm using
|
Posted By: Neil
Date Posted: 29 February 2008 at 11:45am
Yes, I am using v 11.2
I will put my other work on hold now and do the demo
|
Posted By: Neil
Date Posted: 29 February 2008 at 12:04pm
How do I upload the demo file (zip file) ?
Shall I send it to a email address?
|
Posted By: jcollier
Date Posted: 29 February 2008 at 12:04pm
send it to jcollier@optitekinc.com
|
Posted By: Neil
Date Posted: 29 February 2008 at 12:15pm
Posted By: Neil
Date Posted: 29 February 2008 at 12:18pm
I sent the demo to the email address you kindly provided - I hope you can help point out what I may be doing incorrectly
|
Posted By: jcollier
Date Posted: 29 February 2008 at 12:19pm
I got it. I've found the problem. I'm fixing it and will return it shortly.
|
Posted By: Neil
Date Posted: 29 February 2008 at 12:25pm
Posted By: jcollier
Date Posted: 29 February 2008 at 1:42pm
I sent it back to you. Let me know if you didn't get it.
|
Posted By: Neil
Date Posted: 29 February 2008 at 3:16pm
Just got it now - I was away for a few hours. I'll give you feedback ASAP.
Thanks
|
Posted By: Neil
Date Posted: 29 February 2008 at 3:31pm
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
|
Posted By: jcollier
Date Posted: 29 February 2008 at 3:39pm
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
|
Posted By: jcollier
Date Posted: 29 February 2008 at 3:47pm
Ignore the PreviewKeyDown part. It's not right.
|
Posted By: jcollier
Date Posted: 29 February 2008 at 3:59pm
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
|
Posted By: Neil
Date Posted: 29 February 2008 at 4:16pm
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.
|
|