Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form Complete Status

Posted on 2013-12-17
10
Medium Priority
?
287 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
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

927 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