assigning value to control when form opens

B

BRC

Hi all
I have a form that is used to edit "events" the form has a combo box
to select the date and the onupdate event shows all events for that
day in a subform. Clicking on the event opens the "eventfrm" to that
event where it can be edited.
I want to add a cmd button to the form so that the user can add a new
event to that day if it does not already exist. I put a button on the
form with the following code.
***************
Private Sub AddeventBtn_Click()
On Error GoTo Err_addeventbtn_Click
Dim dt As Date
dt = Me.SelDateCB
DoCmd.OpenForm "eventfrm", acNormal, , , acFormAdd, , dt
Exit_addeventbtn_Click:
Exit Sub

Err_addeventbtn_Click:
MsgBox Err.Description
Resume Exit_addeventbtn_Click
End Sub
**************************************
eventfrm has the following code in the onopen event;
*************************
Private Sub Form_Open(Cancel As Integer)
If not IsNull(Me.OpenArgs) Then
Me.dateTB = Me.OpenArgs
Else
End If
End Sub
**************************************************
I get an error that "you can't assign a value to this object"
error message and the Me.datetb= me.openargs is highlighted.
Any suggestions would be appreciated.
Thanks BRC
 
D

Douglas J. Steele

Try moving your code to the form's Load event. The Open event is too soon:
the controls haven't been properly instantiated yet.
 
B

BRC

Try moving your code to the form's Load event. The Open event is too soon:
the controls haven't been properly instantiated yet.

--
Doug Steele, Microsoft Access MVPhttp://I.Am/DougSteele
(no private e-mails, please)







- Show quoted text -

Doug,
Thanks for the input. I ended up moving it to Current event. and it
seems to work as i wanted. the load event didn't cause any errors but
did not assign the correct value to the new event. thanks again.
BRC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top