473,395 Members | 1,464 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,395 software developers and data experts.

Command buttons visible in subform on a per record bases

Hi all,

Not sure if this is possible, but can I change the controls of a
command button on a per record bases in a subform. In my case, I would
like to make a command button visible only if certain fields in a table
are a certain value. Here is the subroutine I've written so far:

Public Sub IsButtonVisible()

'For Access, define some object variables and make connections.
Dim cn As ADODB.Connection
Set cnn = CurrentProject.Connection
Dim rsRepeatInfo As New ADODB.Recordset
rsRepeatInfo.ActiveConnection = cnn
Dim btnRepeatInfo As AccessObject

'Declare variables
Dim strSQL As String
Dim strTestCode As String
Dim strSampleNumber As String
Dim strTestStatus As String

'Get the values from the subform
strTestCode = "='" & Me.txtTestCode.Value & "'; "
strSampleNumber = "='" & Me.txtSampleNumber.Value & "' "

'Build the SQL string
strSQL = "SELECT tblTests.[Test_Status] " & _
"FROM tblSamples INNER JOIN tblTests " & _
"ON tblSamples.[LSTS_Number] = tblTests.[LSTS_Number] " & _
"WHERE tblSamples.[LSTS_Number] " & strSampleNumber & _
"AND tblTests.[Test_Code]" & strTestCode

'Open the recordset
rsRepeatInfo.Open strSQL

'Check for end-of-file (EOF) in recordset
If rsRepeatInfo.EOF Then
strTestStatus = "SIL"
Else
strTestStatus = rsRepeatInfo("Test_Status")
End If

'Make "btnRepeatInfo" visible if "strTestStatus" = RT-SIL or RRT-SIL
If strTestStatus = "RT-SIL" Or strTestStatus = "RRT-SIL" Then
Me.btnRepeatInfo.Visible = True
Else
Me.btnRepeatInfo.Visible = False
End If

'Clear the object variables
rsRepeatInfo.Close
cnn.Close
End Sub
Note: 'Me' actually is 'Forms![frmSelectSet].frmSelectSample.Form' but
removed for clearity.
The above works but makes all the buttons visible/invisible.
Thanks in advance!!
PCB

Nov 13 '05 #1
0 1387

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

Similar topics

1
by: Tim | last post by:
I have one main form that I use to view data as well as add new records. When I click the add new record button, many of the form's controls that arn't needed get set to invisible. When I'm done...
0
by: Arnold | last post by:
Hi there, I have a form to organize bottles in mind, but am unsure if it will work. Here's some background info: Mainform = frmProduct, which contains fields for pricing, status, etc. of...
9
by: Karl Roes | last post by:
Hi All, I would like some advice on Next / Previous record buttons. I have a main form for the client, and a continuous subform listing client transactions. If I open one of these transactions...
2
by: j.mandala | last post by:
This had got to be something obvious that I am too blind to see! Funny problem: one of my users has my application linked to a SQL Server Backend. Front end it Access XP (SP3). The first form...
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...
1
by: Simon | last post by:
Dear reader, In case I have selected a record in the main Form which has no reference records in the SubForm the SubForm is not visible. Is there a possibility to check of the record...
2
by: emc_cos | last post by:
I have a very nice parent child relationship happening between a main form and 8 subforms. The main form is the data entry point for a table that holds textual data like names, notes and the...
14
by: ApexData | last post by:
In my database, I uniformly handle records on a Record by Record basis, in a single form that contains New/Edit/Del buttons. Because I'm dealing with records one at a time, I can easily manage my...
5
by: Susan Bricker | last post by:
I have a command button that I'd like to make "disappear" after being clicked and after the OnClick function has executed. I have tried changing the 'visible' attribute to false while within the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.