473,396 Members | 1,755 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Hiding a command button linking forms

Hi all,

I am trying to hid a command button which links two forms. The forms
are connected by a one-to-many relationship and the second form has
details on the first. But if no details are avaliable I don't want the
command button to appear. I've been working with an "If/Then"
statment, but now the command button never appears.

Here is the statement I have

Private Sub Form_Current()

Dim stDocName As String

stDocName = "Destroyed Files Contents"

If "[Matter Number]" = Me![Matter Number] Then
Destroyed_Form.Visible = True
Else
Destroyed_Form.Visible = False
End If

End Sub

this is the statement linking the two forms

Private Sub Destroyed_Form_Click()
On Error GoTo Err_Destroyed_Form_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Destroyed Files Contents"

stLinkCriteria = "[Matter Number]=" & "'" & Me![Matter Number] &
"'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Destroyed_Form_Click:
Exit Sub

Err_Destroyed_Form_Click:
MsgBox Err.Description
Resume Exit_Destroyed_Form_Click

End Sub
Thanks for any help,

Danthrom

Jul 27 '06 #1
2 1499
Your problem lies here:
If "[Matter Number]" = Me![Matter Number] Then

Me![Matter Number] is never going to equal "[Matter Number]" because
it's text. I think you want the value for [Matter Number], you don't
want to pass it a text string. You probably want something like:
If Forms!SubForm.[Matter Number] = Me![Matter Number] then

I'm most likely wrong on the exact syntax but it's something along
those lines.

danthrom wrote:
Hi all,

I am trying to hid a command button which links two forms. The forms
are connected by a one-to-many relationship and the second form has
details on the first. But if no details are avaliable I don't want the
command button to appear. I've been working with an "If/Then"
statment, but now the command button never appears.

Here is the statement I have

Private Sub Form_Current()

Dim stDocName As String

stDocName = "Destroyed Files Contents"

If "[Matter Number]" = Me![Matter Number] Then
Destroyed_Form.Visible = True
Else
Destroyed_Form.Visible = False
End If

End Sub

this is the statement linking the two forms

Private Sub Destroyed_Form_Click()
On Error GoTo Err_Destroyed_Form_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Destroyed Files Contents"

stLinkCriteria = "[Matter Number]=" & "'" & Me![Matter Number] &
"'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Destroyed_Form_Click:
Exit Sub

Err_Destroyed_Form_Click:
MsgBox Err.Description
Resume Exit_Destroyed_Form_Click

End Sub
Thanks for any help,

Danthrom
Jul 27 '06 #2
I tried

If Forms![Destroyed Files Contents].[Matter Number] = Me![Matter
Number] Then
Destroyed_Form.Visible = True
Else
Destroyed_Form.Visible = False
End If

But it says that the form cannot be found, however the wording is fine.

anymore suggestions?

ManningFan wrote:
Your problem lies here:
If "[Matter Number]" = Me![Matter Number] Then

Me![Matter Number] is never going to equal "[Matter Number]" because
it's text. I think you want the value for [Matter Number], you don't
want to pass it a text string. You probably want something like:
If Forms!SubForm.[Matter Number] = Me![Matter Number] then

I'm most likely wrong on the exact syntax but it's something along
those lines.

danthrom wrote:
Hi all,

I am trying to hid a command button which links two forms. The forms
are connected by a one-to-many relationship and the second form has
details on the first. But if no details are avaliable I don't want the
command button to appear. I've been working with an "If/Then"
statment, but now the command button never appears.

Here is the statement I have

Private Sub Form_Current()

Dim stDocName As String

stDocName = "Destroyed Files Contents"

If "[Matter Number]" = Me![Matter Number] Then
Destroyed_Form.Visible = True
Else
Destroyed_Form.Visible = False
End If

End Sub

this is the statement linking the two forms

Private Sub Destroyed_Form_Click()
On Error GoTo Err_Destroyed_Form_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Destroyed Files Contents"

stLinkCriteria = "[Matter Number]=" & "'" & Me![Matter Number] &
"'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Destroyed_Form_Click:
Exit Sub

Err_Destroyed_Form_Click:
MsgBox Err.Description
Resume Exit_Destroyed_Form_Click

End Sub
Thanks for any help,

Danthrom
Jul 28 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Mr Newbie | last post by:
I was thinking about developing a workflow application yesterday and was musing over the different approaches than one could take in restricting specific actions on a ticket( Form ) at any said...
14
by: Kevin | last post by:
A couple of easy questions here hopefully. I've been working on two different database projects which make use of multiple forms. 1. Where's the best/recommended placement for command buttons...
0
by: andymcintosh85 | last post by:
Hi, I have designed a macro which prints out the first 2 pages of a word document. The Macro is assigned to a command button which is at the bottom of the second page. At the moment, the macro...
2
by: luciegiles | last post by:
Hi, I am creating a database in which users will enter details for one client (record) in several tables via several associated forms. I would like to have a button on each form that takes the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.