Results 1 to 15 of 15
  1. #1
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7

    Combo Box autofill

    Hi,



    I have a database meant to manage courses. In each form there are three semesters listed. When I am on record and mark the status as "inactive" I would like the other semester status' to automatically read inactive too. I would also like this to work for the option "completed," but not for the other options. Also, I only want this to work forward, not backwards to past semesters. I would also be great if once the status automatically updates I could still change it manually if need be.

    Any thoughts?

  2. #2
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    So you have 3 combo boxes with options of 'active' or 'inactive'. If you mark semester 1 'inactive' you want semesters 2 and 3 to also be marked 'inactive', if you mark semester 2 'inactive' you want semester 1 to be left alone but mark semester 3 'inactive' and if semester 3 is marked 'inactive' semster 1 and 2 are left alone?

    Let's assume your combo boxes are named 'sem1', 'sem2' and 'sem3'

    in the ON EXIT event of the SEM1 combo box you can have

    Code:
    me.refresh
    if(sem1 = "inactive") then
        Sem2 = "Inactive"
        Sem3 = "Inactive"
    endif
    I don't know if the me.refresh is going to be necessary for your version of access so you can remove it to start with but the other two lines would work fine. Then you just modify your SEM2 combo box and you should be all set.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    You could have code (I use only VBA) run an UPDATE sql action. Is there a date field for the records? Is there a unique ID field, maybe autonumber?

    The real trick is figuring out what event to run the code in. Perhaps in the checkbox Change event:

    The sql action could be something like:

    CurrentDb.Execute "UPDATE tablename SET fieldname=" & Me.checkbox & " WHERE StudentID=" & Me!StudentID & " AND ID > " & Me!ID
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7
    This seems to be working! One more question.

    If the last sem on the form is Inactive and that semester is also in another form with future semesters, could that selection of inactive be passed to another form?

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Which suggestion is working? Are you changing 3 values (3 comboboxes) of same record or are you modifying 3 records?

    You have more than one form bound to the same record? The record edit will be reflected in all forms bound to it. The other form might have to be refreshed.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7
    Sorry the first suggestion is working. I am modifying three values in the same record that is pulling from a query that does not have Fall 2013 semester in it. So if I change Summer 2013 in the first form to inactive, how can i get it to update Fall 2013 in the next form?

  7. #7
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    You want to change the 3 status fields in another record? Try my suggestion.

    I don't really understand this form setup. Why are there multiple forms displaying semester records? These forms are bound to the same data source?

    Want to provide db for analysis? Follow instructions at bottom of my post.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    I agree, if you can post a sample database with a sample set of data it would be much easier to determine what to give you by way of response.

  9. #9
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7
    Okay, here are two screenshots of the database. In the screenshot of form2 you will see that FA13 status is not filled in even though I entered the code for SU13 in form1.

    Click image for larger version. 

Name:	form2.jpg 
Views:	9 
Size:	160.5 KB 
ID:	9319Click image for larger version. 

Name:	form1.jpg 
Views:	7 
Size:	156.2 KB 
ID:	9320

  10. #10
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    This isn't a sample database it's screenshots. It looks to me like you're trying to carry a rolling 3 term window of classes but doesn't tell anything about how you're doing it or why. If this is a bound form are you really carrying a record of 3 terms for each record so that, for example, fall of 2013 would be repeated on 3 separate records? I can't really tell anything about your data structure or form based on the screen shots, sorry.

  11. #11
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7
    OK, thank you. Unfortunately, I cannot post any sort of copy of the database on here. Thanks for your help.

  12. #12
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    make a copy of the database, take out any personal or sensitivie information, put in some bogus data to help us get the idea of what you're doing , then zip it up and load it to the site. We're not asking for you to post the database in it's entirety either, just the parts that don't work.

  13. #13
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7
    Okay, here is a sample.

    Sample.zip

  14. #14
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    Ok I have to ask this question, is this database in the process of being built or has it been in use for a while. What I'm getting at here is that your structure is not normalized so you are going to have a lot of issues with updating queries, reports, forms etc. Basically every term you will need to design a new form, granted it will be very similar to existing forms but it's still going to need continual maintenance. I'd really recommend you look at how to normalize your structure if you're allowed to/able to at this point in your development.

    What you should have is a table that handles your terms and any items directly related to a specific term (i.e. tuition expense, etc.)

    Code:
    TermID  Term Desc
    1       Spring 2012
    2       Summer 2012
    3       Fall 2012
    A table for classes offered and any data specifically related to the class (i.e. which department administers the class, history dept, psychology dept, is the class active or inactive, etc.)

    Code:
    ClassID  ClassName 
    1        History 101
    2        History 102
    3        Algebra 101
    4        Algebra 102
    Then a table that contains your actual scheduling information and any information directly related to a specific class during a specific term (i.e. a particular room number the class is held, the teacher responsible for the class, etc)

    Code:
    ClassSchedID  ClassID  TermID  ....
    1             1        1  (History 101, Spring 2012)
    2             1        2  (History 101, Summer 2012)
    and so on
    Then if you made a specific class inactive you wouldn't see it in your list of available classes for a specific term unless you reactivated it.

    That's my advice, but for your specific request you do not have an easy way to update your records you would specifically have to have something in your ON EXIT or AFTER UPDATE or ON CHANGE event (I usually use on exit so that's what I'm going to go with here)

    If you mark a STATUS field as INACTIVE you will have to modify your code to not only look on the existing form but for everything in the source table that

    This is what I mean about normalizing your structure and why it will be a pain, you'll have to have code or a query for every possible combination of updates starting with your earliest term, in your case your current earliest item is Fall2011 (let's pretend that we're in the fall of 2011 just for the purposes of this example) You would have to have a query or write code that said IF the FA11 status equals 'Inactive' run an update query that marks the following fields inactive as well SP12 Status, SU12 Status, FA12 Status, SP13 Status, SU13 Status, FA13 Status. If however you marked SP12 Status as 'Inactive' you would only want to update the last five 'status' fields of your table.

    So, for the sake of this example let's say you're updating your FA12 Status to Inactive, you are going to want to change the following fields to 'Inactive' SP13 Status, SU13 Status, FA13 Status. Create a query that will update all of those fields to 'Inactive'

    Then in your ON EXIT property of your FA12 Status put in this code

    Code:
    me.refresh
    if [fa12 status] = "Inactive" Then
        docmd.setwarnings false
        docmd.openquery ("Name of Update Query")
        docmd.setwarnings true
    endif
    you just insert the name of the query you created to perform the update where I have NAME OF UPDATE QUERY

    One other thing to keep in mind is if you keep building your database this way you are, at some point run out of room. Access tables can only handle up to 255 fields and you will rapidly run out of room, you've got 3 years worth of terms in there and you're already at 50 fields. Please consider trying to normalize the structure of your database, it will save you a lot of issues and headaches in the future.

  15. #15
    sblack is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2012
    Posts
    7
    Thank you so much for your help and explanation. I completely understand what you are saying about the structure not quite being right. However, the database is not meant to show courses being offered every semester, it is just meant to be a database of all courses, whether they are inactive or active. The reason there is different forms for each semester is because the course names often change as do the course versions. I wouldn't know how to implement your advice while still being able to add new courses when they come up and change titles where I still have a record of what the old title used to be.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Autofill field based on combo box
    By topp in forum Access
    Replies: 2
    Last Post: 06-26-2012, 04:36 PM
  2. Autofill combo value
    By survivo01 in forum Forms
    Replies: 7
    Last Post: 03-27-2012, 04:41 PM
  3. Combo Cascade with a twist on autofill
    By Huddle in forum Access
    Replies: 1
    Last Post: 02-29-2012, 10:18 PM
  4. Replies: 1
    Last Post: 11-22-2011, 02:36 PM
  5. Autofill
    By evosheas in forum Access
    Replies: 4
    Last Post: 09-20-2011, 02:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums