Access ComboBox save value - ms-access

I use a combobox to select value form a query. and make 2 columns in combobox.
the list will be
John 1
David 2
Michael 3
and expect when I selected John, will save 1 to table. but access save 0 to table, and if select David, will save 1. how can I save to Column 2 value to table?

Related

MS Access VBA outlook code for query output

I have 3 queries. First query has 10 records, 2nd and 3 query has 1 each. The query fields are ID and Name. I want to write a msaccess query, so it opens all 3 queries and create the output in a outlook email as below:
So under name it should have 10+ names or less and ID from 1st query, then 1 record from 2nd query and then the 3rd. it should be in a table format. also it should not ignore duplicate.
Name ID
first 1
second 2
third 3
fourth 4
first 5

Creating a form in access that adds fields to more than table

So I have 3 tables, and I'd like to be able to create form that will add a new row to table 1, and then use that data to add rows on table 3 with values from table 1 and 2. I've included a brief overview of the table structure. Please let me know if I can clarify anything.
Table 1 - Things
Table 2 - TypesofThings
Table 3 - ThingType
Example of records in the tables:
Table1:
ID - 1 Name: "This"
ID - 2 Name: "That"
Table2: (This table is predefined types of things capped at 15)
`ID - 1 TypeName: Yellow`
`ID - 2 TypeName: Red`
`ID - 3 TypeName: Green`
Table3: This is a "transaction" table that matches the field from table 1 to table 2
`ID: 1 Table1_ID:1 Table2_ID:1`
`ID: 2 Table1_ID:1 Table2_ID:2`
`ID: 3 Table1_ID:1 Table2_ID:3`
`ID: 4 Table1_ID:2 Table2_ID:2`
Example Form of what I'd like to be able to do:
Thing Name: "whatever"
[x] yellow
[] red
[x] green
This submission would add a row to table 1 with the name whatever, and then using the values from table 2 and 2 rows to table 3 like:
id:1 table1_id:1 table2_id:1
id:2 table1_id:1 table2_id:3
I have created the form that will add new rows, but I can't figure out how to do the rest. If you guys could point me in the right direction it would be greatly appreciated!
Looks like many-to-many relationship. Conventional data entry structure:
single form bound to table 3 with comboboxes to select items from tables 1 and 2
main form bound to table 2 and subform bound to table 3 with combobox to select items from table 1
main form bound to table 1 and subform bound to table 3 with combobox to select items from table 2
If you want to be able to add items to table that is source for combobox 'on-the-fly' during data entry, look into the combobox NotInList event. MS NotInList event

database table structure to store user location

I have a requirement to store user's proper location & send them newsletters as per them, I would like to understand the best way to store them as I have been finding it challenging to retrieve it after storing.
First of all, the address that needs to be stored is like:-
Country1-City1-SocietyName1-AnyMoreSmallLocation1-...so on.
So, now what I have done so far...
Table 1...
PID Place Parent
1 Country1 0
2 Country2 0
3 City1 1
4 City2 1
5 City3 2
6 Society1 3
n so on
Then
User table where I am keeping location with UID
UID Name PID
1. John 6
2. Sam 7
But at the get call of user location it needs to be like this...society name, city, country. which seems not good as per current design..please suggest.
If each user has only one adress, consider having only one table :
UID Name Country City etc.
But if there is multiple adresses per user, 2 tables (User and Adress):
UID Name
AdresseID UID Country City etc.

Microsoft access iff statement

I've been making an award system in ms access but trying to use the if statement for 2 distinct parameters, i.e. in one class top 3 students get a different amount from what the top 3 students of another class might get. All the data of all classes is in one table.
See:
Student ID Class ID Average Rank Awards
1111 Form4 77.79166667 2
1189 Form4 105 1
1222 Form4 73.41666667 3
1234 Form4 69.95833333 4
1235 Form 3 77.16666667 3
1236 Form 3 72.875 4
1258 Form 3 82.54166667 1
1333 Form 3 77.25 2
1367 Form 2 56.54545455 4
1445 Form 2 75.66666667 2
1447 Form 2 75.72727273 1
1465 Form 2 74.18181818 3
1523 Form 1 76.18181818 3
1542 Form 1 75.51515152 4
1552 Form 1 79.03030303 2
1555 Form 1 79.63636364 1
at the awards column when creating a query the build formula I use i.e. IIf([Rank]=1,1100) gives all student IDs ranked 1 an award of 1100 but I want only form 1 student IDs to get 1100 and the others ranked 1st with different award values please assist.
I think you want something like:
IIF([ClassID] <> "Form 1", IIf([Rank]=1,500), IIf([Rank]=1,1100))
Obviously, you will have to edit the award amount since you didn't specify what you were giving, but the logic should hold true.
If this gets a bit more complicated, you can write a function in VBA (in any code module in the 'modules' section), and use it in the query:
ExpressionName: evaluateAward(ClassID, Rank)
In the function, you can then use nested select case statements. This may be much better for readability.

Keeping some choices in the Table for the Field of Type Dropdown

i am having a Table named
Attributes
which has
id form_id label size sequence_no Type
1 1 Name 200 1 Text
2 1 Age 150 2 Number
3 1 Address 300 3 Textarea
4 1 Gender 200 4 Dropdown
I am having the doubt how can i keep the Choices of the Field of type "Dropdown" in the Table
Eg. For Gender the choices will Male , Female..
Please give me the suggestions...
You simply need a child table like this:
id value_id sequence_no label
4 100 1 Male
4 101 2 Female
Note where id = 4 is all the values for the #4 question.
Sounds like you're trying to build an automagic form that is built from a database?
I would suggest having that table be something like elements and have another table for options which links back to the original id
i.e.
options
id element_id value text
1 4 1 Male
2 4 2 Female
That way for specific types you will be know to look up the options.
You may want another field to specify if its a multiselect or perhaps you could make it another Type.
edit :
you can add another type to this table call dropdown_choice,
and add all the choices of this dropdown to this table,
need to keep in another field the master id of this dropdown choice.