473,549 Members | 2,531 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Conditional Format Button based on value in another table

3 New Member
I have a button on a subform that opens another form (PastMedicalHis tory) I want to change the border color of this button after a user post information into this form. This way the user will know that the task has been done or that information is available for review.

I've been trying to accomplish this by using the On Paint event on the subform. I have been playing with several iterations of the following.
Expand|Select|Wrap|Line Numbers
  1. If Me!Past_Medical_History_T_subform.Form!UpdatedBy.Value = Null Then
  2.     Me.btn_PastMedicalHistory.BorderColor = RGB(255, 224, 0)
  3. Else
  4.     Me.btn_PastMedicalHistory.BorderColor = RGB(32, 56, 100)
  5. End If
"Past_Medical_H istory_T_subfor m" is hidden on the subform. I thought that this would be a way to reference the table field "UpdatedBy" . If the UpdatedBy field value is null then there isn't any information entered.

The unique field that links all forms and subforms is MRN (Medical Record Number).

I realize that if I can get it to work on the subform I will have to move this code to the main form and modify it slightly but for now I am just tying to get it to work on the subform.

Any suggestions would be greatly appreciated!
Aug 21 '19 #1
4 1309
BHo15
143 New Member
I had luck with a DCount on the table that is supporting the form. So you could do something like
Expand|Select|Wrap|Line Numbers
  1. If DCount("*","tbl_TableName","ID = " & Me.ID)>0 Then Me.btn_PastMedicalHistory.BorderColor = RGB(255, 224, 0)
Aug 21 '19 #2
twinnyfo
3,653 Recognized Expert Moderator Specialist
You can also use the recordset of the subform and use the RecordCount properyt of a cloned rescordset. It seems like more work, butit relies on direct usage of the objects at hand, and avoids usage of a Domain Aggregate funciton (DCount) which will work, but is a bad use of system resources.

Expand|Select|Wrap|Line Numbers
  1. Dim rst     As DAO.Recordset
  2. Dim intRcds As Integer
  3.  
  4. Set rst = Me.Past_Medical_History_T_subform.RecordsetClone
  5. If Not (rst.BOF And rst.EOF) Then
  6.     rst.MoveLast
  7.     intRcds = rst.RecordCount
  8. End If
  9. Set rst = Nothing
  10.  
  11. If intRcds = 0 Then
  12.     Me.btn_PastMedicalHistory.BorderColor = RGB(255, 224, 0)
  13. Else
  14.     Me.btn_PastMedicalHistory.BorderColor = RGB(32, 56, 100)
  15. End If
Hope this hepps!
Aug 22 '19 #3
hgillung
3 New Member
Hi!

Thank you for your reply.

I tried the code you suggested. I placed it in the On Paint event in the Details section of the main subform.

It crashed on the line:
Set rst = Me.Past_Medical _History_T_subf orm.RecordsetCl one

I played with other options and it seems to work if I insert "Form" before RecordsetClone.

Set rst = me.Past_Medical _History_T_subf orm.Form.Record setClone

Awesome!

Thank you!
Aug 25 '19 #4
hgillung
3 New Member
Hi!
Thanks for your reply! I really appreciate you taking the time to respond.
I tried the code you suggested, I really liked how simple it was. I just couldn't get it to work. I am sure it was something I was doing and not your code.
Thanks again!
Aug 25 '19 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
5920
by: Mike | last post by:
Here is my situation; I have two tables in a MS-SQL DB. One table with dollar amounts and service codes. I have a second table that I want to move some information into from the first table. The catch is I want to move one field as is from the first table to the second, but the rest of the fields in the second table are calculations based...
2
14894
by: Daniel | last post by:
I use an Access database to basically take data exports, import them, manipulate the data, and then turn them into exportable reports. I do this using numerous macros, and queries to get the data in the format that I need it in order to create the reports that we use. So far this has proven to be successful for the reports that I am doing and...
2
1418
by: PerryC | last post by:
Scenario: FormA: Field1, Field2 (Field1 is a combo box based on a NameTable w/ Name and phone fields) When users choose Field1 with Name1 (in record1 of NameTable), Field2 will automatically reflect Phone1.
3
2457
by: bitoulis | last post by:
Hi, is it possible to use the records of a table as the field names of another table? If yes, how is it done? Thanks in advance Laertes
0
257
by: Leonardo Gangemi | last post by:
How to align right a table based on another table created dinamically? Leonardo
3
8737
by: turtle | last post by:
I have Two tables (Table1 and Table2). Both tables have a common field called part number. Table 1 contains an extra field that i would like to update table 2 to match if the part number matches. I created a join between Table1 and Table 2 but couldn't update Table 2 since the recordset was unupdateable. What i would like: Table 1...
11
2023
by: martipe1 | last post by:
I am sorry if somebody posted this question before, but I already looked for it and I was not lucky to find it. I am working with Access 2003 on an Orders Database, to make it simple: I have two tables, one is TBLCustomers and the other is TBLOrderHeader. Both have the field AgentId, I created a form and I want at the moment the customer is...
3
2594
by: Ronald S. Cook | last post by:
I have a table of keywords (hundreds/thousands of records): KeywordID KeywordName --------- ----------- 1 Apple 2 Orange 3 Pear I then have a table of products (also hundreds/thousands of records):
2
5441
by: Haas C | last post by:
Hi all! I am new to this and trying to learn as best as i can. This group is defiintely helpful in that regards. Anyways, I was wondering if someone can help me with this: I have a table called for example BigTable and I have another smaller table called SmallTable - both tables are joined at the Account field. I want to set up a query...
8
2738
by: Shannon Mathews | last post by:
Ok trying to explain... 1. I have a tblMain that holds the master list of all my checks. 2. I'm currently using a make table query "qryCheckHoldingListCreateTbl" to get a list of all the checks where the "sent" date is null, table called "tblCheckHoldingList" 3. The "tblCheckHoldingList" is viewed via a form "frmCheckHoldingList" where our...
0
7457
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7965
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...
0
6051
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5092
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...
0
3487
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1949
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
771
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...

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.