Re: Combination box
- From: "Evi" <evwool@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Sat, 24 May 2008 20:20:56 +0100
Leaving aside your non-normalised database (see Douglas's post)
Why don't you just base your form on your Tbl320 then your combo box can
filter it to show the required row. Why go to all the trouble of using an
update or append query?
You say
So If a user choose year = 2008 and week = 21
So are you now saying that your combo have 2 columns, one for the week
number and one for the year
Or are you saying that you have 2 combos, one for the week number, one for
the year.
(I'd have thought this second design would be the better)
You could filter a continuous form with these combos with code like this in
the AfterUpdate event of the second combo
If IsNull(Me.Combo1) then
'check if the user has entered a year
MsgBox "Please choose a year"
Else
Me.Filter = "[Weeknb]=" & Me.Combo1 & " AND [Yearnb] = " & Me.Combo2
Me.FilterOn = True
End If
or if have you put your table into an unbound form as a subform and you want
to filter the subform:
If IsNull(Me.Combo1) then
'check if the user has entered a year
MsgBox "Please choose a year"
Else
Me.YourSubformName.Form.Filter = "[Weeknb]=" & Me.Combo1 & " AND [Yearnb] =
" & Me.Combo2
Me.YourSubformName.Form.FilterOn = True
End If
Evi
"Ticotion" <Ticotion@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:09DDC443-0E5C-432C-8B2C-54FD22352F34@xxxxxxxxxxxxxxxx
Hi Eviwill
It is proberbly very simple. I will try to explain it in another way.
My main tabel is called tbl_320 and looks like the following:
ID year week monday tuesday wedensday
1 2008 1
2 2008 2
I have a combo box call year and a combo box called week getting data from
tbl_320.
Then I have a box called monday, one called tuesday and so on relating to
each colounm in tbl_320.
The user should input produced amount in each box based on the selection
criteria year and week.
So If a user choose year = 2008 and week = 21 the monday, tuesday boxes
show the input values for those fields (if any) or the user can input newhave
values.
Hope this is a better explanation
Thanks again for your help
Ticotion
"Evi" wrote:
This still isn't making sense to me.
'The name of the field Produced amount is Monday (eh???). I also have a
field
tuesday, wedensday and so on, where the same thing should happen'.
Are you saying that you have Fields in your table called Monday, Tuesday
Wednesday etc?
(if yes, you may need to check your database design in the TableDesign
newsgroup)
or are you saying that you have text boxes in an unbound form which you
fornamed (in Properties) Monday, Tuesday, Wednesday
Does Tbl320 also contain a field which contains numbers (1, 2, 3 etc)
recordeach week? Or does it contain dates. Are you trying to add a new new
usedto Tbl320 or edit a record already there? ie are you trying to run an
append or an update query?
Is tbl320 set out like some kind of spread*** with the weekdays being
dataas field names and the week numbers typed down the side?
Is there a reason why you can't base a form on this table and enter the
Wednesdaydirectly into the table via the form which you can filter using a combo?
Or do you want your form to total the text boxes Monday, Tuesday
Tbl320because this is an Unbound text box and enter the results into your
soin a field called ProducedAmount next to the Week field with the chosen
number
I think there may be something you have missed out of your explanation.
Evi
"Ticotion" <Ticotion@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:313F6B6B-2147-447F-ADB9-5FFF4F22A307@xxxxxxxxxxxxxxxx
Hi Evi
Name of combo boks is CBO2 which looks up week values in tbl_320.
The name of the field Produced amount is Monday. I also have a field
tuesday, wedensday and so on, where the same thing should happen.
When a user inputs numbers in the "Monday" field or Tuesday field and
weekon,
the user should by pressing a button save the input values for the
somethingchoosen, in tbl_320.table,
If nothing is listed then nothing should be written in the table.
I've tried to use your code but can't realyy get it to work.
Thanks for your help
Ticotion
"Evi" wrote:
It might help you to give details such as name of combo box, name of
readname of field for Produced Amount. it will make it easier for you to
events.the code too. It also saves us having to assign names to them.
Since this is a simple coding problem, I assume you know how to use
So the code in the After Update Event for the combo will be
thatlike
this
Me.ProducedAmount = (DLookup("[LookedUpValue]",
"DatasourceTable2","[WeekNumber]=" & Me.MyCombosName)
You'll need to put in the real names
You will need to decide what to do if there is nothing listed for
theinstance.WeekNumber in your datasource table - look up the NZ function for
have aEvi
"Ticotion" <Ticotion@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:5C75349C-39F8-4950-A88D-ED2D10D2E93E@xxxxxxxxxxxxxxxx
Hi
I have a simple form coding problem.
I have a combination box that contains week numbers. Furthermore I
field for produced amount. When a user selects a weeknumber I want
theform
to find the value in the datasource tabel, so that the input in
produced
amount field are saved here. Can you help me?
Thank you for your help and input
Ticotion
.
- Follow-Ups:
- Re: Combination box
- From: Ticotion
- Re: Combination box
- References:
- Re: Combination box
- From: Evi
- Re: Combination box
- From: Ticotion
- Re: Combination box
- From: Evi
- Re: Combination box
- From: Ticotion
- Re: Combination box
- Prev by Date: Button to delete record on data*** subform
- Next by Date: Re: Filtering problem
- Previous by thread: Re: Combination box
- Next by thread: Re: Combination box
- Index(es):