Generating Text fields from query (1 Viewer)

ledgerr.rob

Registered User.
Local time
Today, 15:22
Joined
Jun 3, 2012
Messages
68
Good morning folks,

I've come across a problem that doesn't make sense to me. I have a form with a combo box on it. Each time the combo box is used or the form is moved to another record it triggers an event to update the text boxes.

I get the information for the text boxes from a query. Everything was working smoothly until I decided to add a text box to the form to be filled in. My thought was I add the column from the query to the code and it will update. No dice. It doesn't recognize any information in the query. But when I run the query as a standalone it sees the text. When i open the table that holds the text, it is still there.

Code:
Private Sub cboDoctor_AfterUpdate()

'update doctor fields on the update of the combo box

If Len(Me.cboDoctor) > 0 Then
    Call DoctorName_Change
Else
    Call DoctorNameBlank_Change
End If

End Sub

'*************************************************************
Private Sub DoctorName_Change()
Me.txtDoctorType = Me.cboDoctor.Column(1)
Me.txtDoctorOffice = Me.cboDoctor.Column(11)
Me.txtDoctorFirst = Me.cboDoctor.Column(2)
Me.txtDoctorLast = Me.cboDoctor.Column(3)
Me.txtDoctorPhone = Me.cboDoctor.Column(4)
Me.txtDoctorEmail = Me.cboDoctor.Column(5)
Me.txtDoctorAddy1 = Me.cboDoctor.Column(6)
Me.txtDoctorAddy2 = Me.cboDoctor.Column(7)
Me.txtDoctorCity = Me.cboDoctor.Column(8)
Me.txtDoctorState = Me.cboDoctor.Column(9)
Me.txtDoctorZip = Me.cboDoctor.Column(10)


End Sub

When i step through the code it shows values for each of the columns except for column 11. It reports as 'null.'

Things I've tried:
Updating the combo box by reselecting the value for the record.
Restarting DB.
Changing from one record in the combo box back to the original record.

Is there a limit of columns that can be used? Column 10 works just fine...

Thanks for any tips.

regards,
rob
 

robslob

Registered User.
Local time
Today, 23:22
Joined
Apr 26, 2015
Messages
27
What does it show for the Column Count for that combo box?
It will tell you within the Format tab of the Property Sheet (assuming AC 2007)
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 23:22
Joined
Sep 12, 2006
Messages
15,689
is the cbodoctor bound to a text field, or a number field

if number then

Code:
 If nz(Me.cboDoctor,0) > 0 Then
    Call DoctorName_Change
Else
    Call DoctorNameBlank_Change
End If

either way, I think you need to test for null, eg with a string

if len(Me.cboDoctor & "")
 

ledgerr.rob

Registered User.
Local time
Today, 15:22
Joined
Jun 3, 2012
Messages
68
What does it show for the Column Count for that combo box?
It will tell you within the Format tab of the Property Sheet (assuming AC 2007)

That did it!

The problem as eluded to by robslob was that the column count for cboDoctor was set to 10, not 11.

This problem was resolved by going to the Property Sheet for cboDoctor, looking at the Format tab of the Property sheet and changing the column count to 11.

Once again, the forum rules all!
regards,
rob
 

Users who are viewing this thread

Top Bottom