473,473 Members | 1,988 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Use of Visible property if matching record found

3 New Member
I am self taught and struggling with a particular problem.
I have created a database to record postcard details using Access 2000.

My main screen (POSTCARD_FORM) shows details of the card and allows users to add comments about the postcard eg "the spire on the church is 50 feet high" .

I have two buttons, an ADD_COMMENTS button and a VIEW_COMMENTS button. The comments are stored in COMMENT_TBL. I would like to be able to open the POSTCARD_FORM and automatically check to see if comments exist in the COMMENT_TBL for the record displayed. If not, I want to set the visible property of the VIEW_COMMENTS button to false. If the user either adds a comment and returns to the POSTCARD_FORM, or moves to the next postcard which already has comments, then the VIEW_COMMENTS button should reappear.

Thanks for your help on this and all the other answers which I have found on this site.
Oct 13 '07 #1
6 2017
MMcCarthy
14,534 Recognized Expert Moderator MVP
Welcome to thescripts.

I am moving your question to the Access forum where it should receive better attention.

Mary
Oct 14 '07 #2
MMcCarthy
14,534 Recognized Expert Moderator MVP
I am self taught and struggling with a particular problem.
I have created a database to record postcard details using Access 2000.

My main screen (POSTCARD_FORM) shows details of the card and allows users to add comments about the postcard eg "the spire on the church is 50 feet high" .

I have two buttons, an ADD_COMMENTS button and a VIEW_COMMENTS button. The comments are stored in COMMENT_TBL. I would like to be able to open the POSTCARD_FORM and automatically check to see if comments exist in the COMMENT_TBL for the record displayed. If not, I want to set the visible property of the VIEW_COMMENTS button to false. If the user either adds a comment and returns to the POSTCARD_FORM, or moves to the next postcard which already has comments, then the VIEW_COMMENTS button should reappear.

Thanks for your help on this and all the other answers which I have found on this site.
OK I have a couple of questions.

Are the comments displaid in a subform?
If so what is the foreign key in the COMMENT_TBL which references the primary key of the main table and what is the name of the corresponding textbox on the form?
Oct 14 '07 #3
Lewis Wood
3 New Member
OK I have a couple of questions.

Are the comments displaid in a subform?
If so what is the foreign key in the COMMENT_TBL which references the primary key of the main table and what is the name of the corresponding textbox on the form?

Hi Mary,
Each button opens a separate form.

The ADD_COMMENTS_FRM accepts comments, contributors name and contact information

The VIEW_COMMENTS_FRM just displays the comments.

The relevant field in the COMMENTS_TBL is simply COMMENT.


One of the many options I tried is to open a query which counts COMMENT where the POSTCARD_ID matched on both tables but all I need to do is detect if just one comment exists as that would satisfy my criteria to keep the View button visible. Whilst that was inefficient, it did work, but I could not find a way to pass the result to an event in order to test if the criteria was satisfied. Also I am not certain if the On Current event is the correct one to use. My query also displayed on screen which is not what I want either.

Thanks for your help.


The POSTCARD_TBL is linked to the COMMENTS_TBL via POSTCARD_ID.
Oct 14 '07 #4
MMcCarthy
14,534 Recognized Expert Moderator MVP
I think from what you have said the forms On Current event is the correct place.

You could try something like the following code.

Expand|Select|Wrap|Line Numbers
  1. If NZ(DCount("[COMMENT]","COMMENT_TBL","[POSTCARD_ID]=" & Me.POSTCARD_ID),0) = 0 Then
  2.     Me.VIEW_COMMENTS.Visible = False
  3. Else
  4.     Me.VIEW_COMMENTS.Visible = True
  5. End If
  6.  
You may also need to add a refresh or requery in the close or unload event of the ADD_COMMENTS_FRM form. For example ...

Expand|Select|Wrap|Line Numbers
  1. Forms!POSTCARD_FORM.Requery
Oct 14 '07 #5
Lewis Wood
3 New Member
I think from what you have said the forms On Current event is the correct place.

You could try something like the following code.

Expand|Select|Wrap|Line Numbers
  1. If NZ(DCount("[COMMENT]","COMMENT_TBL","[POSTCARD_ID]=" & Me.POSTCARD_ID),0) = 0 Then
  2.     Me.VIEW_COMMENTS.Visible = False
  3. Else
  4.     Me.VIEW_COMMENTS.Visible = True
  5. End If
  6.  
You may also need to add a refresh or requery in the close or unload event of the ADD_COMMENTS_FRM form. For example ...

Expand|Select|Wrap|Line Numbers
  1. Forms!POSTCARD_FORM.Requery

Hi Mary,

Thanks for your suggestion. It did not work first time but after I understood what NZ() is all about and worked through the DCOUNT requirements, I changed your line to the following which worked a treat.

If Nz(DCount("[COMMENT]", "Comments tbl", "[comments tbl]![Postcard_ID]= [Forms]![Postcard_Form]![Postcard_ ID]"), 0) = 0 Then etc......

Maybe Access 2000 is a little different from your version as my version does not like the '&' character and I could not quite follow the placement of the '='sign.

Thanks to your input I now have an elegant solution and understand a little more about Access so that's a good result all round.
Thanks again
Lewis
Oct 14 '07 #6
MMcCarthy
14,534 Recognized Expert Moderator MVP
Not sure why you had a problem with the syntax in Access 2000 but at least you have it working for you now.

Mary
Oct 14 '07 #7

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

Similar topics

5
by: Lyn | last post by:
Hi, I have a form which contains a number of subforms in different pages of a tab control. In the detail section of each subform, I list records related to the main form record, but from...
3
by: Susan Bricker | last post by:
Greetings. I have three forms that are open at the same time. They are related and cascading. The first form (frmEventAdd) is the anchor. Each event can have many Trials. The second form is...
1
by: mike | last post by:
Hi, I'd like advice from a .NETer. I have a loadcombo routine which sets the selectedindex to -1 if it's an "add record", but then it goes to a security routine which, based on permissions...
1
by: jodyblau | last post by:
I have a form that is in Continuous form. In each record there is a button next to the a date box. When the button is pushed, the calendar control is set to visible (rather than in a seperate pop...
6
by: Robert | last post by:
Quick question about the visible property on a form control. I have a label that displays a message if a certain criteria is met. By default the label is visible. I want access to compare a...
18
by: Drayno241 | last post by:
I'm working in access 2002. I have three tables : 1- District Data (Student ID, name, grade, etc) 2- Rosters (RRec ID,Campus, Teacher ID) 3- Students on Roster(SRec ID, RRec ID, Student ID) ...
1
by: paquer | last post by:
I have a form with a field who's Visible property by default is set to false. If another field meets a certain criteria, then the visible property is set to true. This form shows multiple...
1
by: sora | last post by:
Hi, I've developed a MFC program under VS 6.0. My debugger *was* working fine and I've used it often for my project. Then, one day, the errors below appear and they prevent me from using the...
4
by: thecheyenne | last post by:
Hi there everybody; Fresh from reading my Access VBA for Dummies, I'd like to update my database about activities on a school outing. Here's what I'd like to achieve. The school outing costs...
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
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...
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
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,...
1
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...
0
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...
0
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...
0
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 ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.