Solved

Form Complete Status

Posted on 2013-12-17
10
266 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
SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

 
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 500 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 …
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

730 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