Return correct On Change data from cbo to txt box (1 Viewer)

Zydeceltico

Registered User.
Local time
Today, 03:57
Joined
Dec 5, 2017
Messages
843
Hi All -

I have a form (frmMillInspection) that has a combobox (cboPartNumber) where the user picks a Part Number. I also have a text box (txtPartDrawing). When the user makes a selection in cboPartNumber, txtPartDrawing is populated with the part drawing. (I should note that one must also choose the Plant Name and the Workstation first before making a selection in Part Number as they all cascade on each other).

The data for PartNumber and PartDrawing both reside in tblPartDrawings.
I have the following fields in tblPartsDrawing in this order: Part_ID(PK), PartNumber, Workstation_FK, DWGType, and PartDWG.

cboPartNumber is populated from the field PartType and txtPartDrawing is populated from field PartDWG.

cboPartNumber stipulates a column count of 3; Column Widths = 0;0.7875;0

The code for the On Change event on cboPartNumber is:
Private Sub cboPartNumber_Change()
Me!txtPartDrawing = Me!cboPartNumber.Column(2)
End Sub

....and this works as intended.


Now my question:

I have another form (frmWeldAssembleInspection) which has a similar condition based on tblWeldAssemble. On form frmWeldAssembleInspection I have cboAssemblyNumber and txtStandardDrawing. Making a selection in cboAssemblyNumber should populate txtStandardDrawing. The data for cboAssemblyNumber is the 2nd column in tblAssemblyTypes and txtStandardDrawings should populate from the 3rd column (AssemblyDWG) in tblAssemblyTypes.

I have the column count for cboAssemblyNumber set to "3." The column width is set to 0.7875";0" - which returns the correct values to cboAssemblyNumber although I do not know why. It does not follow the logic that I thought it would.

The code I have inserted on the Change event for cboAssemblyNumber is:
Private Sub cboAssemblyNumber_Change()
Me!txtStandardDrawing = Me!cboAssemblyNumber.Column(2)
End Sub

This does not return anything to txtStandardDrawing.

Also, I do not understand why the column width being set to 0.7875";0" returns the correct data for the drop down selections in cboAssemblyNumber as I have only stipulated an "open" width for the first column which I *thought* would have been the PK in tblAssemblyTypes rather than the second field which is AssemblyType.

I have tried various numbers (0-3) in Me!cboAssemblyNumber.Column(#) to no avail. If I add a 0; at the beginning of the current (and working) 0.7875";0" nothing is returned to cboAssemblyNumber. I would have expected that 0";0.7875";0" would have been the correct input for column width but it doesn't work.

I would love to have an explanation of how Column Count and Column Width are intended to operate - as well as some guidance on why my first condition works and my second doesn't.

Thank you in advance,

Tim
 

Attachments

  • QC DB Rev 201810161.accdb
    1.5 MB · Views: 47
Last edited:

Ranman256

Well-known member
Local time
Today, 03:57
Joined
Apr 9, 2015
Messages
4,339
col widths have nothing to do with the selection.
but, say we have a combo box of US States: the 2code and the name
NY, New York
SC,South Carolina

If the bound col is 1.
and col widths are 0;1 (the code is invisible)
the user will see 'New York', but the actual value is the bound col = NY.

If you assign "New York" to the combo box , the value will be NULL, because the 2code is the assignment and there is no New York value.

Make sure your bound values and your reading column value is straight.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:57
Joined
May 7, 2009
Messages
19,169
your forgot to include AssemblyDWG field on your combo's rowsource.
 

Attachments

  • QC DB Rev 201810161.zip
    169.2 KB · Views: 51

Users who are viewing this thread

Top Bottom