Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Microsoft Access 2007 Help

  • 05-03-2011 03:08PM
    #1
    Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭


    Hi, I hope this is in the right forum as this seemed the most appropriate one.

    At the moment I'm building a toxicology database in Access. What I'm trying to do however is to have a combo boxin the form with several values.

    What I would like it to do is say if a particular value in the first combo box is selected, I would like another combo box to be produced with values relating to just that value.

    So say I have a combo box containing the samples taken e.g. Hair, blood, urine, liver etc

    When I select blood, I would like another combo box to be produced with options such as where the blood was taken from e.g. heart, subclavian etc

    Apologies if I haven't explained it very well but any help would be greatly appreciated.


Comments

  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    You will need to create a piece of Visual Basic code to handle what happens when the combo box changes... If you look up the properties of the combo box on the form you will see the onchange setting:

    cboSearchOnChange.gif

    you then create a piece of code to control what happens when the Combo box changes... this will take a the format similar to below:

    Private Sub combobox1_OnChange()
    {
    code for updating the options in other fields...
    }

    You should get a book on Visual Basic for Access.. It's easy enough..


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Thanks, I was hoping I wouldn't have to get into the coding side but I guess I'll have to give it a try.

    Also, I have encountered a problem whereby I have entered about 2000 drug types into a combo box. When I try to make a selection in a table, all the drugs and values are there.

    However when trying to make a selection from the combo box in the form, there is only about 100 of the drugs available for selection. Is there anyway to fix this?

    Took me almost 2 days to enter them so don't want it to have been a waste!

    Thanks again.


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    Well you've obviously had the confidence to create the database, so creating the code for the combo box is something you should not be afraid of.. You dont need to become an expert in Visual Basic, you just need to find out the functions required to do what you need it to do..

    Regarding the combo box not showing all of your list, I'm not sure if there is a limitation on the number of items that can be on a combo box... Is the list truncated at a particular letter or can you work out any reason why some are being shown and others are not... ?


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Well you've obviously had the confidence to create the database, so creating the code for the combo box is something you should not be afraid of.. You dont need to become an expert in Visual Basic, you just need to find out the functions required to do what you need it to do..

    Regarding the combo box not showing all of your list, I'm not sure if there is a limitation on the number of items that can be on a combo box... Is the list truncated at a particular letter or can you work out any reason why some are being shown and others are not... ?

    Thanks, it's just this database is one of about 6 projects I'm working on at the moment so my time is stretched to the max as it is :( I've gotten a book on it now though so will get cracking on it again tonight.

    Yeah the list stops after the chemicals beginning with "A". It shows the first value in the B list and then there's an "Á" symbol and that's where it stops. It all works fine in the table view though.


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    it sounds like it has an issue with the special character.. On a quick google search there, the limit seems to be 65535 items in the combo box, so I'm pretty sure it's nothing to do with a limitation of number of items... Try changing that special character to something else as a test and see if it lists past that item...

    oh, and it's a good idea to use a naming convention when you are going to be coding... for example, for a combo box that contains drug items, the normal naming convention would be cmbDrugs.. It's not mandatory to do this, but it makes coding much easier.

    I think if you wrote out pseudo code for what you want to do, and then find out how to do each bit separately, this would be the easy way to progress... But from what you say, I think it would involve create some sort of SQL query based on the value selected in combobox1 and then changing the rowsource value of combobox2 and using the requery so that it will carry the results of this query,


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    it sounds like it has an issue with the special character.. On a quick google search there, the limit seems to be 65535 items in the combo box, so I'm pretty sure it's nothing to do with a limitation of number of items... Try changing that special character to something else as a test and see if it lists past that item...

    oh, and it's a good idea to use a naming convention when you are going to be coding... for example, for a combo box that contains drug items, the normal naming convention would be cmbDrugs.. It's not mandatory to do this, but it makes coding much easier.

    I think if you wrote out pseudo code for what you want to do, and then find out how to do each bit separately, this would be the easy way to progress... But from what you say, I think it would involve create some sort of SQL query based on the value selected in combobox1 and then changing the rowsource value of combobox2 and using the requery so that it will carry the results of this query,

    Thanks for all the help, really appreciate it. The character  isn't something I entered in to the combo box, it just appears at the end of the combo box in the form so I'm not sure how to delete it, any ideas?

    Yeah I'll try and get that sorted, it's a little bit daunting thoguh as I've never coded anything in my life!


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    Thanks for all the help, really appreciate it. The character  isn't something I entered in to the combo box, it just appears at the end of the combo box in the form so I'm not sure how to delete it, any ideas?

    If you could take a screen capture of this an upload it, it might help me to see what is happening... Usually when something like this happens, the best thing to do is to find at which item it stops.. then remove this item temporarily to see if it is isolated to this item, if the item contains something that is incompatible with combobox..

    Make sure that you have the latest service pack version down for Microsoft Office. Access is far from perfect and you can come across horrible nonsensical bugs, but I've never come across one that I wasnt able to solve through either googling or applying a service pack..


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Here it is in table view and you can see it transitions from A - B with no problems:

    335e98m.jpg

    This is the form:

    f2pxqo.jpg


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    okay well what's the next item after Baclofen.. can you look up the table behind it.. cos it seems that one of the fields in the record for Baclofen OR the record after it, contains something that Access does not like..


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Here is a list of what's after Baclofen:

    sy8i7k.jpg

    Should I try deleting the 2 records following baclofen and see if it helps?


  • Advertisement
  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    okay well from your table the only fields I can see are Drug, Therapeutic Level, Toxic Level, Fatal Level... but nothing in those fields seems like it would cause trouble... usually with database stuff, if it displays everything up to a particular record, then there is usually an issue with that record... I would temporarily remove Baclofen and the following record and then have a look at the combo box again.... try that..


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Sorry to be a pain but I'm trying to delete the individual values from the combo box but I'm having no luck at all.

    I went onto the table in design view, selected Drug, then went into Lookup and Row source and tried to remove them there but it wouldn't let me.


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    I went onto the table in design view, selected Drug, then went into Lookup and Row source and tried to remove them there but it wouldn't let me.

    It may be locked by some of the forms that you have open... Can you close down any open forms and just open the table on it's own...


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    I have the table open on its own now but it still won't let me edit the row source. When I select a word and try to delete it says "the text is too long to be edited".


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    I'm not sure what that error means.. I used mainly Access 2003 when I was developing, and it's not an error I'm familiar with.. You will need to work through that yourself... The only advice I can give is that it would be my opinion that there is something in one of the fields of the record for Blacofen or the record after it that is causing the displaying of the list to terminate...


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    No problem, thanks very much for all the help. I'll let ya know how I fare at it but I'll leave it for today as it's giving me a headache :p


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    I'm actually tearing my hair out at this stage. I've tried several things to fix it none have worked so far!

    Firstly, I went to the row source of the table and copied all the code in notepad. I then set up a new table with a lookup form and pasted the code in, in sections purposely leaving out the 4 files after baclofen. That didn't work as the drop down box came out really messy with numbers all over the place.

    Today I said feck it, and started to manually enter all the data in again, this time leaving in the values after baclofen and went on until I finished the letter B.

    Then I created a form to see if the combo box worked, and it did!! Displayed all the values entered even beyond baclofen. So I continued to enter data and just decided to stop after the letter D and low and behold, it doesn't work anymore and now the last value in the combo box is benztropine!

    I'm out of ideas and really need to get this to work properly :(


  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    I've sent you a private message
    Firstly, I went to the row source of the table and copied all the code in notepad. I then set up a new table with a lookup form and pasted the code in, in sections purposely leaving out the 4 files after baclofen. That didn't work as the drop down box came out really messy with numbers all over the place.

    Notepad doesnt havent the power to handle the formatting.. You should use Excel to do this sort of operatioin..
    Today I said feck it, and started to manually enter all the data in again, this time leaving in the values after baclofen and went on until I finished the letter B.

    Re-entering the information is not gonna solve this problem.. There seems to be a problem, possibly with some of the content you are entering.. There maybe be a particular character or symbol in some of the records that is causing trouble, and if that character is used in relation to one of the drugs then it is likely to be used in relation to a number of the drugs.. i.e. you will have to replace it in ALL of these records..


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Thanks, I've contacted you there. The only symbols used that I can see causing a problem are the < and > signs.


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    Finally managed to get it working :D I re-entered all data into a table and used the table as the row source for the combo box and now all values are showing in the combo box!

    Now I just have to figure out how to produce a new combo box based on a selection made in a previous combo box!


  • Advertisement
  • Closed Accounts Posts: 23,718 ✭✭✭✭JonathanAnon


    sorry I meant to respond.. I couldnt get any of those databases open.. tried a few of the conversion tutorials on youtube and nothing worked..


  • Registered Users, Registered Users 2 Posts: 2,983 ✭✭✭Cherry_Cola


    sorry I meant to respond.. I couldnt get any of those databases open.. tried a few of the conversion tutorials on youtube and nothing worked..


    It's no problem, thanks very much for the help.

    I may be back to you in regards to synchronising combo boxes but I'll have a crack at it first and see how I get on.


  • Registered Users, Registered Users 2 Posts: 13 TommyQ


    Hey Cherry,

    Just noticed this thread. Could you post the database as you have it now and i'll have a look at whats going wrong. I could post my suggestions but it would be a lot easier if I had the data to work with.

    Cheers,
    Laoistom


Advertisement