Full Version: Filling A Field From A Combo Box Column Or A Text Field If Combo Box Not Used
UtterAccess Discussion Forums > Microsoft® Access > Access Forms
johnp
This is a goofy problem, i am sure.

I have an entry field called Pat_Medication, behind that entry field is a combo box with multiple columns. If they select one of the values in the combo box, I fill various other fields from the columns. This works great, they can use the combo box values, or enter a value manually. i want to fill a field called Pat_Med_Generic with the data in column 8, if the user uses the combo box pull down, if they don't, i want to put the value that was manually entered in the Pat_Medication field into the field Pat_Med_Generic.



My logic looks like this:
CODE
Me.Pat_Med_Generic = Me.Medication_ID_Combo.Column(8)

'Add logic to check to see if blank, if blank will fill with data from field Pat_Medication

If Me.Pat_Med_Generic Is blank Then
Me.Pat_Med_Generic = Me.Pat_Medication
End If


The first part,
Me.Pat_Med_Generic = Me.Medication_ID_Combo.Column(8) works fine, its just i am trying to tell the program, if they don't use a value in the combo box, i.e. enter it manually, then put the value entered in the field Me.Pat_Medication into the Me.Pat_Med_Generic field.


Any suggestions, or see what I am doing wrong?





I tried to use me.pat_med_Generic is null, or is " " but either way, it either gives me an error or will not fill the field. I also tried if Me.Medication_ID_Combo.Column(8) is blank or null or " " but neither seemed to work properly.





Any suggestions?
Thanks in advance!

LionelRoodyn
Try using the OnNotInList event
johnp
QUOTE (LionelRoodyn @ Jun 23 2011, 04:26 PM) *
Try using the OnNotInList event

Thanks but that didn't work, i think the On Not in list will only work if the combo field properties are set to * 'limit to list' which mine is not.


* site that indicates this: http://www.databasedev.co.UK/not_in_list.html
yougee5a3a
in my logic, user entered manually to Pat_Medication field then will choose or not the Medication_ID_Combo
if it's then i think you just need 2 events for handle it

First :
Private Sub Pat_Medication_AfterUpdate()
Me.Pat_Med_Generic = Me.Pat_Medication
End Sub

Second :
Private Sub Medication_ID_Combo_AfterUpdate()
If IsNull(Me.Medication_ID_Combo) Or Me.Medication_ID_Combo.Value = "" Then
Me.Pat_Med_Generic = Me.Pat_Medication
Else
Me.Pat_Med_Generic = Me.Medication_ID_Combo.Column(8)
End If
End Sub

Just in my logic hat_tip.gif
Regards,

'Gie
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.