The record source for the add_contact form is contact_list - which is the
name of my table.
Here is the code for the button:
-------------
Option Compare Database
Private Sub Combo0_Click()
End Sub
Private Sub Combo0_Undo(Cancel As Integer)
End Sub
Private Sub cboAlphaCateg_AfterUpdate()
Me!lookup_query_subform.Requery
End Sub
Private Sub cboAlphaFirst_AfterUpdate()
Me!lookup_query_subform.Requery
End Sub
Private Sub cboAlphaLast_AfterUpdate()
Me!lookup_query_subform.Requery
End Sub
Private Sub cboAlphaDept_AfterUpdate()
Me!lookup_query_subform.Requery
End Sub
Private Sub AddContact_Click()
On Error GoTo Err_AddContact_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "add_contact"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_AddContact_Click:
Exit Sub
Err_AddContact_Click:
MsgBox Err.Description
Resume Exit_AddContact_Click
End Sub
Private Sub Command36_Click()
On Error GoTo Err_Command36_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "add_contact"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command36_Click:
Exit Sub
Err_Command36_Click:
MsgBox Err.Description
Resume Exit_Command36_Click
End Sub
Private Sub Command37_Click()
On Error GoTo Err_Command37_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "add_contact"
stLinkCriteria = "[department]=" & "'" & Me![cboAlphaDept] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command37_Click:
Exit Sub
Err_Command37_Click:
MsgBox Err.Description
Resume Exit_Command37_Click
End Sub
Private Sub Command39_Click()
On Error GoTo Err_Command39_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "add_contact"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command39_Click:
Exit Sub
Err_Command39_Click:
MsgBox Err.Description
Resume Exit_Command39_Click
End Sub
Private Sub Command40_Click()
On Error GoTo Err_Command40_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "add_contact"
stLinkCriteria = "[department]=" & "'" & Me![cboAlphaDept] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_Command40_Click:
Exit Sub
Err_Command40_Click:
MsgBox Err.Description
Resume Exit_Command40_Click
End Sub
----------------
John W. Vinson said:
On Thu, 11 Dec 2008 08:24:01 -0800, Annemarie
I'm not using a query, I'm using forms.
Yes. And your Form is based on a Query. That query is the form's
Recordsource.
There is no SQL view for my forms.
Every bound form has a Query. It may be a hidden query Access keeps in
the
background, but it has a query.
Just to clarify, my lookup_form has a
button that opens an add_contact form. The add_contact form is data
entry, so
it doesn't display records, but just a blank record. When I open the
add_contact form regularly, it opens correctly. When I use the new
button I
made on the lookup_form, it just opens a blank form, with no fields.
When I
view it in datasheet like you suggested, it does only display the
headers.
But I'm not using a query.
Well, not one that you built maybe, but you ARE using a query - maybe a
wizard
did it!
Please post the code of the button that opens the form, and also open the
form
in design view. View its Properties. What's in the Recordsource property
on
the Data tab?