Trying to Requery a Text Box on a Form

bconner

Registered User.
Local time
Today, 16:25
Joined
Dec 22, 2008
Messages
183
I have a Form that I am using for Reporting. I have a text box on the form that has a query set as its Control Source. I would like for the text box to update based on a selection from a combo box. The query underlying the text box basically takes the value of the combo box as its criteria. I have tried using the DoCmd.Requery "txtReportDescription" but is doesn't work. Below is the code I am using. The text box just displays #Name?
Any help is greatly appreciated....


Code:
Private Sub CmbReportList_Change()
DoCmd.Requery "txtReportDescription"
 
You can't have SQL as the control source of a textbox. A DLookup would be one solution, though the best solution would depend on your specifics.
 
I tried the below workaround and it still doesn't work


Code:
Private Sub CmbReportList_Change()
Dim RptRejCode As String
Dim RptUnresponded As String
Dim RptFsc616 As String
Dim RptCpcNonContracted As String
RptRejCode = "Returns Detail for Selected Rejection by Selected Billing Area"
RptUnresponded = "Returns Detail for all Unresponded A/R by Selected Billing Area"
RptFsc616 = "Returns Detail for FSC 616 for Selected Billing Area"
RptCpcNonContracted = "Returns Detail for Payers Specifically Not Contracted to Pay for CPC"
 
If CmbReportList.Value = "ATB By Rejection Code" Then
TxtReportDescription.Value = RptRejCode
Else
If CmbReportList.Value = "ATB Unresponded" Then
TxtReportDescription.Value = RptUnresponded
Else
If CmbReportList.Value = "FSC 616 Report" Then
TxtReportDescription.Value = RptFsc616
Else
If CmbReportList.Value = "Specifically Not Contracted CPC" Then
TxtReportDescription.Value = RptCpcNonContracted
 
TxtReportDescription.Visible = True
End If
End If
End If
End If
End Sub
 
Define "doesn't work". Error? Incorrect result?
 
BTW, if you can just add a second column to the combo rowsource, your solution is simple:

Me.TxtReportDescription = Me.CmbReportList.Column(1)

Also, you probably want the after update event rather than the change event, which fires with each keystroke.
 
Paul,
That worked, thank you for your help I appreciate it.
 

Users who are viewing this thread

Back
Top Bottom