Form button opens blank form

A

Annemarie

I have a button on a form that when you click on it, opens a data entry form.
When I click on the button, it opens the form, but it's blank. There are no
fields displayed. Here is the SQL for the button:
-------------------------------
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
 
G

Gina Whipp

Annemarie,

It might be the underlining query to the from 'add_contact. You might want
to take a look at that query and see if it allows you enter records.
 
J

John W. Vinson

I have a button on a form that when you click on it, opens a data entry form.
When I click on the button, it opens the form, but it's blank.

This will happen if two conditions are true: the Form's recordsource query
doesn't return any records (so you don't see any existing data), and it isn't
updateable (so you don't see the new record either).

Try opening the form's Recordsource query as a datasheet. Does it show just
the fieldname headers? If so my guess is correct.

Fix the error in the query and try again. If you need help doing so please
post the SQL view of the query, and a description of the table or tables
involved.
 
A

Annemarie

I'm not using a query, I'm using forms.
There is no SQL view for my forms. 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.
 
J

John W. Vinson

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?
 
A

Annemarie

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
 
G

Gina Whipp

Looks like it's the RecrodSource for the form.

Go to Design View
From the Menu select Properties and make sure you are on the All tab, once
the Property Window opens
The very first selection should be the RecordSource, select the elipse
button (the one with the dots on it)
In the Window that opens go to the upper right under File and select SQL.
Copy that and paste it here so we can read it and see what's happening...

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
Annemarie said:
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:
Yes. And your Form is based on a Query. That query is the form's
Recordsource.


Every bound form has a Query. It may be a hidden query Access keeps in
the
background, but it has 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?
 
A

Annemarie

I get a popup warning that says "You invoked the Query Builder on a table. Do
you want to create a query based on the table?"



Gina Whipp said:
Looks like it's the RecrodSource for the form.

Go to Design View
From the Menu select Properties and make sure you are on the All tab, once
the Property Window opens
The very first selection should be the RecordSource, select the elipse
button (the one with the dots on it)
In the Window that opens go to the upper right under File and select SQL.
Copy that and paste it here so we can read it and see what's happening...

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
Annemarie said:
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?
 
J

John W. Vinson

The record source for the add_contact form is contact_list - which is the
name of my table.

Is there a Filter on the form? What about its Allow Additions and Allow Edits
properties?
 
A

Annemarie

There is no filter on either the lookup_form or the add_contact form. The
Allow Additions and Allow Edits on the problem form (add_contact) are all set
to yes. The Allow Additions on the main form (lookup_form) is set to yes, but
the Allow Edits on that form is set to no. I set everything to yes on both
forms and still had the same problem.
 
J

John W. Vinson

There is no filter on either the lookup_form or the add_contact form. The
Allow Additions and Allow Edits on the problem form (add_contact) are all set
to yes. The Allow Additions on the main form (lookup_form) is set to yes, but
the Allow Edits on that form is set to no. I set everything to yes on both
forms and still had the same problem.

I'm baffled, Annemarie. All I can suggest is that you create a new form from
scratch and see if it has the same problem. I'd suggest copying and pasting
the controls but that might just copy the problem.
 

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