Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Form Complete Status

Posted on 2013-12-17
10
Medium Priority
?
281 Views
Last Modified: 2013-12-19
Hi - I feel this is easy but rather complicated to explain.

firstly, I'm using Access 2010.

I have two tables called tbl_contacts & tbl_questions

I have two forms called frm_questions1 & frm_questions2

The record source for both the above forms is from tbl_questions.  At the top of the form, I've got a section for 'Contacts'.  This basically allows me to choose a name from a drop down box and it automatically completes all the other fields about this person that are stored in the 'tbl_contacts' table.  This way I don't have to type the persons details in each time.  

As mentioned above, I've created two forms.  'frm_questions1' & 'frm_questions2' that share the same record source. (It's important they are in two separate forms which look different from one another).

On the first form 'frm_questions1' I have two buttons which say;

- 'Click here to complete questions 1'  
- 'Click here to complete questions 2'  

I would like to have a status appear underneath these buttons that show if these forms have been completed or not.

So, if all the values in question 1 get completed it will display a label under this button for 'Questions 1', saying 'Complete'.  If the questions haven't been started or are incomplete, then it will display a message saying 'Incomplete'.

The same applies for 'Questions 2'.

If you're able to give me an example to which I can tweak for my own application that will be very helpful.

Hope this makes sense. Happy to clarify more...
0
Comment
Question by:CptPicard
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 4
10 Comments
 
LVL 40

Expert Comment

by:als315
ID: 39724827
You can, for example, count Null values in answers.
Something like:
IIF(dcount("*", "Form's recordsource", "isnull(Answer)")>0, "Incomplete", "Complete")
0
 

Author Comment

by:CptPicard
ID: 39724886
Hi - the problem is that it's two forms sharing the same record source.  So the first form would populate half the table and the second form will populate the other half.  Thus if I use the above, it will look to see if the entire table has been completed.    Which is why I'm guessing the best way would be to include each text field and check box somehow within the code to see if it's been completed.

I can get it to work for the first form because I've set the on current event to

Me.lblquestion1comp.Visible = (DCount("*", "tbl_questions1", "contact_id = " & Nz(Me.contact_id, -1)) > 0)

Me.lblquestion1incomp.Visible = (DCount("*", "tbl_questions1", "contact_id = " & Nz(Me.contact_id, -1)) = 0)

This checks to see if this particular field has been completed or not.  If it has, it will display the 'Complete' label. If it hasn't, it will display the 'Incomplete' label.

But I can't seem to get the status label to display 'Complete' or 'Incomplete' under the button for 'Questions 2'.  

I thought about passing a value to a hidden field when the form is opened.  Therefore, if a value is entered into this field, the code would execute to display the status 'Complete' and hide the status 'Incomplete' under the button 'Questions 2'.  Would be better if it was to check all fields but I'm not sure how that would be possible with multiple choice questions.
0
 

Author Comment

by:CptPicard
ID: 39727354
I've not heard anything back so I've decided to change the way it should work to make it less complicated.

I now have 2 tables and 1 form.

On the form I have two buttons and 4 labels. 2 labels under each button on top of each other, but I want only one of these labels displayed under each button.  The labels are; 'complete' & 'Incomplete'

If there's a value and it's associated with the Contact_ID in table 1 and 2 then it will display the label 'Complete'.  If there's no value (Contact_ID) entered into these tables, then the label will display 'Incomplete'.

Here's an example of what I've got which doesn't work properly.

Private Sub Form_AfterUpdate()

If Me.lblComplete.Visible = (DCount("*", "tbl_1", "Contact_ID = " & Nz(Me.Contact_ID, -1)) > 0) Then
Me.lblComplete.Visible = True
Me.lblIncomplete.Visible = False
End If

If Me.lblComplete.Visible = (DCount("*", "tbl_1", "Contact_ID = " & Nz(Me.Contact_ID, -1)) = 0) Then
Me.lblComplete.Visible = False
Me.lblIncomplete.Visible = True
End If

End Sub

It's important that when it's looking in the 2 different tables that it's looking for and associating the correct Contact_ID, otherwise it's pointless.   So if it can find the same Contact_ID it will display the 'Complete' label on the form and if it can't find the Contact_ID it will display the 'Incomplete' label on the form.

Hope this makes more sense.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
LVL 40

Expert Comment

by:als315
ID: 39727356
Can you upload sample DB?
0
 

Author Comment

by:CptPicard
ID: 39727367
Not really, that's a bit difficult as I can't upload it as it is and it'd take a long time to change it to make it suitable to upload to the web.
0
 
LVL 40

Expert Comment

by:als315
ID: 39727458
You should start from testing of dcount. Add button to your form and add code to it:
Dim n as long
n = DCount("*", "tbl_1", "Contact_ID = " & Nz(Me.Contact_ID, -1))
msgbox n
Test result for completed and incompleted questions
0
 

Author Comment

by:CptPicard
ID: 39727813
I've created two buttons and put the above code in the 'on click' event and changed the table name in the code above to look at both tbl_1 and tbl_2 respectively.  If I have the same Contact_ID in table 1 and table 2 then both buttons will prompt '1'.  If I have only the same Contact_ID in tbl_1 then it shows '1' for the first button and '0' for the second button.  So I assume this works fine.
0
 

Author Comment

by:CptPicard
ID: 39728876
Hi Als315.  What's next :)
0
 
LVL 40

Accepted Solution

by:
als315 earned 2000 total points
ID: 39729436
If you are sure in result of dlookup, you can change code to (for first table):
Dim n as long
n = DCount("*", "tbl_1", "Contact_ID = " & Nz(Me.Contact_ID, -1))
If n > 0 then
   Me.lblComplete.Visible = True
   Me.lblIncomplete.Visible = False
else
   Me.lblComplete.Visible = False
   Me.lblIncomplete.Visible = True
endif

Now you should find proper place for this code. I don't see your form and it is difficult to advice, but you should place this code to some action on form, where data are changed

May be you can make some screenshots?
0
 

Author Closing Comment

by:CptPicard
ID: 39729492
Thank you for your time.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Preparing an email is something we should all take special care with – especially when the email is for somebody you may not know very well. The pressures of everyday working life stacked with a hectic office environment can make this a real challen…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question