Solved

Form Complete Status

Posted on 2013-12-17
10
232 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 39

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
 
LVL 39

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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 39

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 39

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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now