Adding to a listbox

bobby

Registered User.
Local time
Today, 23:21
Joined
Apr 29, 2004
Messages
28
Guys, im doing a university assignment. The user selects an item from a combo box. I want this item to be added to a listbox - is there a way to do this without using vba code and only using queries and stuff like that ?

The item should also be removeable from the listbox if needed. Any ideas ?
 
bobby said:
Guys, im doing a university assignment. ......

Is it that time of year again already??? :rolleyes:


What is the rowsource of the listbox & combobox? Query / list ????
 
The combo box is:

SELECT tblPlayers.Forename & ' ' & tblPlayers.Surname
FROM tblClubs
INNER JOIN tblPlayers ON tblClubs.Club_ID=tblPlayers.Club_ID
WHERE (((tblClubs.Club_ID)=Forms!frmAdd_Result!cboHomeTeams.value));

And the listbox doesnt have a rowsource at the minute. But i want it to show the value of two combo boxes in different columns.

So say for example combo 1 = "Apples" and combo 2 = "10" i want to the listbox to show :

Column 1 Column 2
``````` ````````
Appes 10

I know the columns arnt really visible in listboxes but i got them working using vba but were not allowed to use it.
 
I am a little confused. No VBA? That seems an odd request.

Are you not allowed to even use Me.Refresh etc in coding etc?

i want it to show the value of two combo boxes in different columns.

Are these two combo box values "related" at all?
 
bradcccs said:
I am a little confused. No VBA? That seems an odd request.

Are you not allowed to even use Me.Refresh etc in coding etc?



Are these two combo box values "related" at all?

Well by no vba i mean no adding and deleting and lots of procedures, etc. I guess a little refresh/set focus/validation, etc, is ok.

I'll explain.

The system holds football results between two teams. It records which players scored and how many goals they scored.

So:

combo box 1 : who scored the goal (a list of players are in here )
combo box 2 : how many goals did they score (a list from 1 to 10)

Listbox : i want this to hold the information from combo 1 and combo 2.

Eg:

Scorer : Scored 3 goals
Scorer : Scored 1 Goal

etc ...

Thanks.
 
Ahhh, 'tis making more sense now.

Combo 1: Rowsource = Players names
Combo 2: Rowsource = # Goals

(Combo 2 is not real intuitive - A text box would serve a better purpose here. What happens when Harry Kewell scores 11 goals in a game. Not likely but why have you db limited by design unneccessarily)

Presuming you wish to store these values (once selected) in a tbl storing game results/goals. (ie: MatchID / PlayerID / NumberGoals). This table will become the rowsource of the listbox (Tbl_MatchGoals)

Simply create and "Append Query" that uses Combo box 1 (& 2 if you make it a combo box) as the field expression and MatchID as the criteria statement.

You will need a "Submit" button to activate the Append Query from the form, and then refresh the ListBox to display relative results.

As for removing the entry. You will need a Delete Query that will delete the selected record (in the listbox) from the Tbl_MatchGoals.

Clear as a muddy soccer field??
 
bradcccs said:
What happens when Harry Kewell scores 11 goals in a game. Not likely

More likely than Tony Vidmar managing such a feat.
Remind me though, how many did Archie Thompson score?
 
You can always rely on an Aussie to destroy a db structure. I seem to manage that on a regular basis without leaving my chair.

Re: How many?
?? 13 ?? - Unlucky for some (American Somoans)
 
I think it was 14 against American Samoa. :)

P.S. Please take Craig Moore back. :D
 
A little stuck

Hey, that was very helpful and i think im almost there.

I'm just stuck on a few things. I have two tables involved at this point, one called Match and one called Goals.

Match - this tracks, which team played which, and on what date
Goals - this holds the matchID, the clubId, the player who scored and in which minute.

I can insert a record into match, because thats easy, match_id autoincrements.

When inserting into Goals, i need the match_id so that i can track which match the player scored in.

I have made a select statement and i can get the match ID. But i need to insert a record into tblGoals using the value from this select statement.

Can i use a sql query within an sql statement ? probably not. Or would i have to store this value from the sql query somewhere else - like inj a hidden text box?

Hope you understand ?
 
Seem to remember that the score board attendent lost count and credited us with an extra goal.

Was some debate over 13 or 14 goals. Either way, it would've been real handy to be able to "bank" a few and use them in other matches.

Hmm now lets see . . . .

Craig ...
Craig ...

No sorry, no record of Craig Moore here.
Looks like he will have to stay. (Or he will be placed in a detention centre for illegal immigrant status).
 
bobby said:
When inserting into Goals, i need the match_id so that i can track which match the player scored in.

You have in essence solved you own dilemna.

On your Goals scored form, you will need:

Combo Box 1: MatchID - Select Match
Combo Box 2: ClubID - Select Club
Combo Box 3: PlayerID - Select Player
Text Box: Enter number of goals (To permit for the return of Archie Thompson)

These four combos form the basis for you Append Query that inserts into the Tbl_Goals.

Mind you, this is assuming that you are required to use an individual input form with combos. The design sounds like a good use for a subform to me, but if you are required to do it this way then eh? Who am I to argue with an education institution?? ;)
 
Well,that didnt completely answer my question but thanks to your reply i have thought of a better solution.

If i split the form up. Originally the form comprised of this :

User specifies home team and away team
user specifies total goals scored by home and away team
user specifies who scored the goals.

But if i split the form up so that :
Form1
`````
User specifies home team and away team
User specifies Total goals scored by home and away team

Form2
`````
User specifies who scored the goals.

This will actually solve many design issues and make thigns much easier to process. Thanks!
 
My apologies.

I had assumed that you were already using a seperate form for the Match & Goals. (Hence the subform suggestion rather than two seperate forms).

Should have recalled whose mother assumption is.

Apologies.
 
*Bobby whips bradcccs with a metal chain *

:D

Thats ok, thanks for ya help :D
 
:o

Was just about to call it quits and go to bed.

BUT if the whips and chains are out then . . . . . .
 
lol :D

How do i run queries and/or macros from vba ?
 
docmd.openquery "QueryName"


Now do I detect a certain student getting lazy and asking "easy" questions.

And who permitted you to use VBA now anyway? ;)


Re: Macros
Do Not Use Them.
End of discussion Re: Macros
 
bradcccs said:
docmd.openquery "QueryName"


Now do I detect a certain student getting lazy and asking "easy" questions.

And who permitted you to use VBA now anyway? ;)


Re: Macros
Do Not Use Them.
End of discussion Re: Macros

I did try but i got an error whdn doing this :

Docmd.OpenQuery "qryAddMatch"

Error: This action/method requires a query name argument.

Im not sure what this means though.
 

Users who are viewing this thread

Back
Top Bottom