Button to combox to table interaction issues.

Sweet, you rock! So 2 things after implementing that.

1) I keep getting "Compile Error" Invalid use of property when I use the combobox.

2) The button displays a ton of blank values, since the columns have different amounts of lines, anyway to fix that?
 
I forgot to mention, you should also remove the OnSelect code of the dropdown--there's no need to do anything when the drop down is selected.

1. What line is it highlighting?

2. No, you have a table, there's 2406 lines. Some of those lines have null values for certain fields but every column has 2406 lines because columns are part of the table.

My guess is that you haven't laid our your table properly. A database isn't a spreadsheet. I suggest you read up on normalization (https://en.wikipedia.org/wiki/Database_normalization) and structure your tables properly. I bet your field names in Gen shouldn't be field names, but instead should be values in a field.

Suppose you had a table to hold foods and their types. You wouldn't store it like this:

ID, Meat, Vegetable, Fruit
1, Beef, Potatoes, Tomatoes
2, Chicken, Lettuce, Apples
3, Pork, , Oranges
4, Shrimp, ,

Instead you would use this structure moving the food types from field names to values in the table:

ID, Food, FoodType
1, Beef, Meat
2, Potatoes, Vegetable
3, Tomatoes, Fruit
4, Chicken, Meat
5, Lettuce, Vegetable
6, Apples, Fruit
7, Pork, Meat
8, Oranges, Fruit
9, Shrimp, Meat

I believe your field names should be in the table itself describing the type of value associated with it. Looks like your other table isn't structure properly either. Again, read up on normalization.
 
Alright, thank you so much again for all your help. I removed the whole select.value and it is working now. I will look into normalization, but I think we are all good to go!

If you ever need help with anything Verizon Fios related, let me know ;)
 
Sorry! 1 last thing I promise. I changed my table like you suggestion and read the article.

Now the code stopped working, what things would I need to modify in your code, I assume it would be simple?
 

Attachments

  • 1111.PNG
    1111.PNG
    16.8 KB · Views: 131
With your new setup, you need to create a query:

Code:
SELECT Gen.ID, Gen.Name, Gen.NameType
FROM Gen
ORDER BY Rnd(ID);

Name that 'RandomName'. Then use this code for your button:

Code:
Private Sub artbutton_Click()
' populates screen with random name from NameType user selected

str_name = "Error"

If IsNull(Me.selectname.Value) Then MsgBox ("Error - No NameType Selected") Else str_name = DLookup("[Name]", "RandomName", "[NameType]='" & Me.selectname.Value & "'")


 Me.arttext.Value = str_name


End Sub
 

Users who are viewing this thread

Back
Top Bottom