Subform Combo Box Needs Current Values Looked Up

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

On a Task the subform there is a pull-down (cboTask_WBS_ID). When a user
enters a new task (txtTask_ID), the WBS pull-down should be populated with a
value from the ValidWBS table......this has worked in the past but is not
working now. I have gone into the Entry Form and tried to enter a new task
to already existing tasks. The WBS pull-down is empty. Can anyone shed some
light on this to help out?
Here is the On Current event that is attached to the subform:
Private Sub Form_Current()
On Error Resume Next

Dim lGovtReq_ID As Long
Dim SQLStr As String

If Nz(Me.txtTask_ID, "") <> "" Then
lGovtReq_ID = DLookup("GovtReq_ID", "qryFindGovtReqForWBS", "Task_ID = "
& Me.txtTask_ID)
SQLStr = "SELECT WBS_ID, WBS_Number, WBS_Description FROM ValidWBS WHERE
GovtReq_ID = " & lGovtReq_ID & " ORDER BY WBS_Number"
Me.cboTask_WBS_ID.RowSource = SQLStr
Else
Me.cboTask_WBS_ID.RowSource = ""
End If

If Nz(Me.cboTask_WBS_ID, "") <> "" Then
Me.txtTask_WBSDescription = Me.cboTask_WBS_ID.Column(2)
Else
Me.txtTask_WBSDescription = ""
End If


End Sub
 
Hi,



Seems to me that

Me.cboTask_WBS_ID.RowSource = ""


got executed, which occurs if


Nz(Me.txtTask_ID, "") <> ""


is false. A debug step by step will probably reveal what is going wrong.


It is also possible that there is just no record where


"GovtReq_ID = " & lGovtReq_ID


Have you check if the DLookup returns an appropriate value? If it returns
null and error trapping is "ON ERROR RESUME NEXT", well, that may also
explain a lot. If you use that kind of error trapping, insert

Debug.Assert Err.Number =0

at critical points. That just assert that you assumed no error would have
occurred yet. If you do add the line just after the DLookup and then, the
code finds the assertion fails, then you know you have forget to validate
the txtTask_ID value before making the DLookup.




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top