Can someone please take a look at this and help me?
I have a form frmPROJECT with an unbound list box containing a string from a query. When I click on the command button to enter data for a new project, I want the unbound list box contents to go into a control called "txtPROJ_IDAdd" on the frmPROJECT_UPDATE. The code I have is below but I keep getting an "Invalid use of Null" message. If I click on the list box first to highlight the control and THEN click the cmdADDPROJ button -- it works. How do I get the focus to the list box so the user doesn't have to be trained to click the list box before clicking the button?
TIA!
<snip>
Private Sub cmdADDPROJ_Click()
On Error GoTo Err_cmdADDPROJ_Click
Dim stDocName As String
Dim strPROJ_IDAdd As String
stDocName = "frmPROJECTADD"
'Store the project id from the list box
strPROJ_IDAdd = Forms!frmPROJECT!lstNextProj_id
'Open frmPROJECTADD
DoCmd.OpenForm stDocName, , , acFormEdit
'Populate the project id number
Forms!frmPROJECTADD!txtPROJ_IDAdd = strPROJ_IDAdd
Exit_cmdADDPROJ_Click:
Exit Sub
Err_cmdADDPROJ_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdADDPROJ_Click
End Sub
</snip>
PenelopeC
~~~>-/O~~~~~swimming right along
I have a form frmPROJECT with an unbound list box containing a string from a query. When I click on the command button to enter data for a new project, I want the unbound list box contents to go into a control called "txtPROJ_IDAdd" on the frmPROJECT_UPDATE. The code I have is below but I keep getting an "Invalid use of Null" message. If I click on the list box first to highlight the control and THEN click the cmdADDPROJ button -- it works. How do I get the focus to the list box so the user doesn't have to be trained to click the list box before clicking the button?
TIA!
<snip>
Private Sub cmdADDPROJ_Click()
On Error GoTo Err_cmdADDPROJ_Click
Dim stDocName As String
Dim strPROJ_IDAdd As String
stDocName = "frmPROJECTADD"
'Store the project id from the list box
strPROJ_IDAdd = Forms!frmPROJECT!lstNextProj_id
'Open frmPROJECTADD
DoCmd.OpenForm stDocName, , , acFormEdit
'Populate the project id number
Forms!frmPROJECTADD!txtPROJ_IDAdd = strPROJ_IDAdd
Exit_cmdADDPROJ_Click:
Exit Sub
Err_cmdADDPROJ_Click:
MsgBox Err.DESCRIPTION
Resume Exit_cmdADDPROJ_Click
End Sub
</snip>
PenelopeC
~~~>-/O~~~~~swimming right along