combo box in subform - please help!

S

SandyR

I have a form called dailylogs based on a table called tbldailylogs. The
primary key of this table is the field tdate.

I have a subform in a container called [team subform]. This is based on the
table tblcrews, which contains the crew id as the primary key, and tdate as a
foreign key.

The parent and child fields in the subform container are tdate.

I have a combo box in the subform, based on a query SELECT TDATE, CREWID
FROM TBLCREWS WHERE TDATE = ME.PARENT!TDATE. I also have a button to create
a new crew.

i have several problems - the first is that when the form is opened, it asks
me to enter the parameter me.parent!tdate. The second is that if I enter a
value for the parameter, the drop down in the combo box still shows me
everything. The third problem is that when I make a selection from the drop
down, the form beeps and refuses to update the field. The fourth problem is
that when I add a new crew using the button, it does not become the current
record.

The code for the button is:
Private Sub cmdcreatecrew_Click()
'---------------------------------------------------------------------------------------
' Procedure : cmdcreatecrew_Click
' DateTime : 2/12/2007 15:31
' Author : rosensan
' Purpose : create a new record in the crew file, and set the current
' crew number to the new crew number.
'---------------------------------------------------------------------------------------
Dim rst As ADODB.Recordset
On Error GoTo Err_cmdcreatecrew_Click
Set rst = New ADODB.Recordset
Set rst.ActiveConnection = CurrentProject.Connection
rst.Open "tblcrews", , , adLockOptimistic
rst.AddNew
rst!tdate = Me.tdate
rst.Update
rst.Requery
Exit_cmdcreatecrew_Click:
Set rst = Nothing
Exit Sub

Err_cmdcreatecrew_Click:
MsgBox Err.Description
Resume Exit_cmdcreatecrew_Click

End Sub
 

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