The command button on my forms doesn't work, any clues why?

  • Thread starter Thread starter GHouse
  • Start date Start date
G

GHouse

I'm trying to link one form to another by a reference number which is in both
forms. I've used the command button wizard which takes me to the other form
but not to just the records I want to see. This worked fine in my 2003 access
database.
 
If it worked in A2003, you probably moved to A2007, and you need to tell it
your database is in a trusted locations.

You can do that through:
Office Button | Access Options | Trust Center | Trust Center Settings
 
Thanks for the advice but I'm afraid it didn't work. I think there is
something wrong with the Wizard but I'm not sure.
 
In A2007 its an 'embedded' Macro. In A2003 its an Event Procedure. I don't
understand why it doesn't work as it is a wizard. Thats what makes me think
that it's the disk thats faulty.
 
I'm confused. You can't create embedded macros in A2003, so I don't
understand how you could have created the code in A2003 and have it not
working in A2007?

The other way around makes sense: If you created a button tied to an
embedded macros in A2007, then you may find A2003 doesn't know what to do
with it.
 
did you ever resolve this problem ? ?

i have also converted to access 2007 from access 2003 and have encountered
the same exact problem you describe . i used the command button
extensively to transfer control from a primary form to a sub form with
specific detail records. this procedure no longer functions properly using
access 2007.

if someone has responded with a solution, kindly refer me to that info

thanks mike
 
Mike, it's not clear how you are approaching this.

Forms in Access 2007 have a FilterOnLoad property.
Set this to No. If it's set to Yes, it may load with an old filter applied,
so the record you want is not in the form.

Let us know if that makes a difference. If not, provide more detail on how
you are passing the value from one to the other.
 
i have checked both forms [ primary and detail ] and the property setting for
" filter on load " is set to " no "..

using access 2003, i used the command button wizard to create the link from
my primary form to a detail form. i used the check box " open form with
specific records " and then selected a field from primary form and a field
from detail form . the field names were the same and used the match button
< > to link the two fields.

i select a specific record in the primary form and when clicking the command
button, it opened the sub form with only those records matching the linked
fields.

however using the exact same procedure, access 2007 opens all records in
the sub form. the only differences that im aware of is that access 2003
uses event procedure and 2007 uses an embedded macro. since all the coding
is automatically generated, and not edited by me, im not sure what is
happening.

i have tried this on several different databases using access 2007 and all
attempts have failed

all my data files have been placed in a trusted file location
 
Okay, let's check we are talking about the same thing.

"Subform" is a special term in Access, referring to a form that is within
another form. When you open the main form, the subform opens in it. When you
talk about "opening a subform", this is actually a completely different
form, opening in its own window, is it?

Pase the code the wizard created for you for the Click event procedure of
your command button. And please tell us the data type of the fields used in
the expression; that is, if you open your table in design view, is it a Text
field? a Number field? a Date/Time field? ...?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

MIKE said:
i have checked both forms [ primary and detail ] and the property setting
for
" filter on load " is set to " no "..

using access 2003, i used the command button wizard to create the link
from
my primary form to a detail form. i used the check box " open form with
specific records " and then selected a field from primary form and a
field
from detail form . the field names were the same and used the match
button
< > to link the two fields.

i select a specific record in the primary form and when clicking the
command
button, it opened the sub form with only those records matching the linked
fields.

however using the exact same procedure, access 2007 opens all records in
the sub form. the only differences that im aware of is that access
2003
uses event procedure and 2007 uses an embedded macro. since all the
coding
is automatically generated, and not edited by me, im not sure what is
happening.

i have tried this on several different databases using access 2007 and all
attempts have failed

all my data files have been placed in a trusted file location

Allen Browne said:
Mike, it's not clear how you are approaching this.

Forms in Access 2007 have a FilterOnLoad property.
Set this to No. If it's set to Yes, it may load with an old filter
applied,
so the record you want is not in the form.

Let us know if that makes a difference. If not, provide more detail on
how
you are passing the value from one to the other.
 
the subform i am referring to is a different form opening in its own window.
it is definitely not a subform within a form.

the link fields are both text fields with the same exact field names.

Allen Browne said:
Okay, let's check we are talking about the same thing.

"Subform" is a special term in Access, referring to a form that is within
another form. When you open the main form, the subform opens in it. When you
talk about "opening a subform", this is actually a completely different
form, opening in its own window, is it?

Pase the code the wizard created for you for the Click event procedure of
your command button. And please tell us the data type of the fields used in
the expression; that is, if you open your table in design view, is it a Text
field? a Number field? a Date/Time field? ...?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

MIKE said:
i have checked both forms [ primary and detail ] and the property setting
for
" filter on load " is set to " no "..

using access 2003, i used the command button wizard to create the link
from
my primary form to a detail form. i used the check box " open form with
specific records " and then selected a field from primary form and a
field
from detail form . the field names were the same and used the match
button
< > to link the two fields.

i select a specific record in the primary form and when clicking the
command
button, it opened the sub form with only those records matching the linked
fields.

however using the exact same procedure, access 2007 opens all records in
the sub form. the only differences that im aware of is that access
2003
uses event procedure and 2007 uses an embedded macro. since all the
coding
is automatically generated, and not edited by me, im not sure what is
happening.

i have tried this on several different databases using access 2007 and all
attempts have failed

all my data files have been placed in a trusted file location

Allen Browne said:
Mike, it's not clear how you are approaching this.

Forms in Access 2007 have a FilterOnLoad property.
Set this to No. If it's set to Yes, it may load with an old filter
applied,
so the record you want is not in the form.

Let us know if that makes a difference. If not, provide more detail on
how
you are passing the value from one to the other.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

did you ever resolve this problem ? ?

i have also converted to access 2007 from access 2003 and have
encountered
the same exact problem you describe . i used the command button
extensively to transfer control from a primary form to a sub form with
specific detail records. this procedure no longer functions properly
using
access 2007.

if someone has responded with a solution, kindly refer me to that info

thanks mike

:

I'm trying to link one form to another by a reference number which is
in
both
forms. I've used the command button wizard which takes me to the other
form
but not to just the records I want to see. This worked fine in my 2003
access
database.
 
Option Compare Database
Option Explicit
Private Sub Command7_Click()
DoCmd.Close
End Sub
Sub Form_Current()
On Error GoTo Form_Current_Err
If ChildFormIsOpen() Then FilterChildForm
Form_Current_Exit:
Exit Sub
Form_Current_Err:
MsgBox Error$
Resume Form_Current_Exit
End Sub
Sub ToggleLink_Click()
On Error GoTo ToggleLink_Click_Err
If ChildFormIsOpen() Then
CloseChildForm
Else
OpenChildForm
FilterChildForm
End If
ToggleLink_Click_Exit:
Exit Sub
ToggleLink_Click_Err:
MsgBox Error$
Resume ToggleLink_Click_Exit
End Sub
Private Sub FilterChildForm()
If Me.NewRecord Then
Forms![SUB - CAR REPAIRS].DataEntry = True
Else
Forms![SUB - CAR REPAIRS].Filter = "[CARCODE] = " & Me![CARCODE]
Forms![SUB - CAR REPAIRS].FilterOn = True
End If
End Sub
Private Sub OpenChildForm()
DoCmd.OpenForm "SUB - CAR REPAIRS"
If Not Me![ToggleLink] Then Me![ToggleLink] = True
End Sub
Private Sub CloseChildForm()
DoCmd.Close acForm, "SUB - CAR REPAIRS"
If Me![ToggleLink] Then Me![ToggleLink] = False
End Sub
Private Function ChildFormIsOpen()
ChildFormIsOpen = (SysCmd(acSysCmdGetObjectState, acForm, "SUB - CAR
REPAIRS") And acObjStateOpen) <> False
End Function

the above is the code that the command button wizard created in the event
procedure
using access 2003. all worked fine until i started making some revisions
to my forms using access 2007 and tried to recreate new command buttons in
access 2007...


Allen Browne said:
Okay, let's check we are talking about the same thing.

"Subform" is a special term in Access, referring to a form that is within
another form. When you open the main form, the subform opens in it. When you
talk about "opening a subform", this is actually a completely different
form, opening in its own window, is it?

Pase the code the wizard created for you for the Click event procedure of
your command button. And please tell us the data type of the fields used in
the expression; that is, if you open your table in design view, is it a Text
field? a Number field? a Date/Time field? ...?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

MIKE said:
i have checked both forms [ primary and detail ] and the property setting
for
" filter on load " is set to " no "..

using access 2003, i used the command button wizard to create the link
from
my primary form to a detail form. i used the check box " open form with
specific records " and then selected a field from primary form and a
field
from detail form . the field names were the same and used the match
button
< > to link the two fields.

i select a specific record in the primary form and when clicking the
command
button, it opened the sub form with only those records matching the linked
fields.

however using the exact same procedure, access 2007 opens all records in
the sub form. the only differences that im aware of is that access
2003
uses event procedure and 2007 uses an embedded macro. since all the
coding
is automatically generated, and not edited by me, im not sure what is
happening.

i have tried this on several different databases using access 2007 and all
attempts have failed

all my data files have been placed in a trusted file location

Allen Browne said:
Mike, it's not clear how you are approaching this.

Forms in Access 2007 have a FilterOnLoad property.
Set this to No. If it's set to Yes, it may load with an old filter
applied,
so the record you want is not in the form.

Let us know if that makes a difference. If not, provide more detail on
how
you are passing the value from one to the other.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

did you ever resolve this problem ? ?

i have also converted to access 2007 from access 2003 and have
encountered
the same exact problem you describe . i used the command button
extensively to transfer control from a primary form to a sub form with
specific detail records. this procedure no longer functions properly
using
access 2007.

if someone has responded with a solution, kindly refer me to that info

thanks mike

:

I'm trying to link one form to another by a reference number which is
in
both
forms. I've used the command button wizard which takes me to the other
form
but not to just the records I want to see. This worked fine in my 2003
access
database.
 
Out of all that, I assume that this is the bit that opens your secondary
form:
Private Sub OpenChildForm()
DoCmd.OpenForm "SUB - CAR REPAIRS"
If Not Me![ToggleLink] Then Me![ToggleLink] = True
End Sub

It doesn't look like you have specified any filter or where condition here,
so yes: it probably does open all records.
 
the subform i am referring to is a different form opening in its
own window.
it is definitely not a subform within a form.

Please stop calling it a "subform". What you have is a dependent
form or linked form, but not a subform.What is the code in the command button's on click event that opens
this dependent form?

the link fields are both text fields with the same exact field
names.

Allen Browne said:
Okay, let's check we are talking about the same thing.

"Subform" is a special term in Access, referring to a form that
is within another form. When you open the main form, the subform
opens in it. When you talk about "opening a subform", this is
actually a completely different form, opening in its own window,
is it?

Pase the code the wizard created for you for the Click event
procedure of your command button. And please tell us the data
type of the fields used in the expression; that is, if you open
your table in design view, is it a Text field? a Number field? a
Date/Time field? ...?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

MIKE said:
i have checked both forms [ primary and detail ] and the
property setting for
" filter on load " is set to " no "..

using access 2003, i used the command button wizard to create
the link from
my primary form to a detail form. i used the check box " open
form with specific records " and then selected a field from
primary form and a field
from detail form . the field names were the same and used the
match button
< > to link the two fields.

i select a specific record in the primary form and when
clicking the command
button, it opened the sub form with only those records matching
the linked fields.

however using the exact same procedure, access 2007 opens all
records in the sub form. the only differences that im
aware of is that access 2003
uses event procedure and 2007 uses an embedded macro. since
all the coding
is automatically generated, and not edited by me, im not sure
what is happening.

i have tried this on several different databases using access
2007 and all attempts have failed

all my data files have been placed in a trusted file location

:

Mike, it's not clear how you are approaching this.

Forms in Access 2007 have a FilterOnLoad property.
Set this to No. If it's set to Yes, it may load with an old
filter applied,
so the record you want is not in the form.

Let us know if that makes a difference. If not, provide more
detail on how
you are passing the value from one to the other.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

did you ever resolve this problem ? ?

i have also converted to access 2007 from access 2003 and
have encountered
the same exact problem you describe . i used the command
button extensively to transfer control from a primary form
to a sub form with specific detail records. this procedure
no longer functions properly using
access 2007.

if someone has responded with a solution, kindly refer me
to that info

thanks mike

:

I'm trying to link one form to another by a reference
number which is in
both
forms. I've used the command button wizard which takes me
to the other form
but not to just the records I want to see. This worked fine
in my 2003 access
database.
 

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

Back
Top