473,587 Members | 2,526 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_F orm_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_F orm_Click:
MsgBox Err.Description
Resume Exit_Destroyed_ Form_Click

End Sub
Thanks for any help,

Danthrom

Jul 27 '06 #1
2 1509
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_F orm_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_F orm_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_F orm_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_F orm_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
2161
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 stage. One approach I have used on other systems is to prevent the action buttons appearing. For example, if one did not have the Role of Administrator, one would be prevented from deleting a ticket not created by oneself. However, it did occur...
14
4956
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 for things like delete, save, edit, cancel buttons - in the footer, or on the form detail section? 2. If in the footer, how do you add them to the tab order?
0
938
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 works fine, but the command button is being shown on the print out too. How can i adopt hiding the command button into my vb code? Many thanks Andrew
2
2142
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 user directly to the next form. If it is a new record I want the form to load with a blank form but pulling across the ClientID (unique identifier) but if a record already exists then link by the ClientID. So if going from frmInitial to frmFamily some...
0
8219
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8349
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7978
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8221
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3882
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.