PC Review


Reply
Thread Tools Rate Thread

Automatically generating text entries from combo box

 
 
Steve
Guest
Posts: n/a
 
      9th Feb 2011
Hi

I have a table with three columns which contain banded funding rates
eg

Band - Day Rate - Residential Rate
F - 22495 - 42303
G - 32967 - 49069

On the input form there are two combo boxes where the user selects the
band (ie F or G) and whether the day or residential rate applies
(these are coded D or R in the combo box.)

There is a text box on the form for entering the actual funding
amount. Can this be generated automatically based on the input from
the two combo boxes (eg, Band F, Residential, would be 42303.)

If so, how?

Many thanks
Steven Thompson
 
Reply With Quote
 
 
 
 
Bob Quintal
Guest
Posts: n/a
 
      9th Feb 2011
Steve <(E-Mail Removed)> wrote in
news:86cceb65-214f-44ce-80d5-(E-Mail Removed)
m:

> Hi
>
> I have a table with three columns which contain banded funding
> rates eg
>
> Band - Day Rate - Residential Rate
> F - 22495 - 42303
> G - 32967 - 49069
>
> On the input form there are two combo boxes where the user selects
> the band (ie F or G) and whether the day or residential rate
> applies (these are coded D or R in the combo box.)
>
> There is a text box on the form for entering the actual funding
> amount. Can this be generated automatically based on the input
> from the two combo boxes (eg, Band F, Residential, would be
> 42303.)
>
> If so, how?
>
> Many thanks
> Steven Thompson
>


in the after_update event for each combobox,select the event procedure
option and add the following Visual Basic code:
IF Band = "F" then
if Rate = "D" then
Me.ActualFundingAmt = 22495
else ' rate must be R
Me.ActualFundingAmt = 42303
end if
Else ' Band is G
if Rate = "D" then
Me.ActualFundingAmt = 32967
else
Me.ActualFundingAmt = 49069
End if
End if

Note you may want to provide some preliminary tests to prevent the
calculation if either combobox is null or empty.
--
Bob Q.
PA is y I've altered my address.
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      11th Feb 2011
That's very helpful Bob, thanks. What if I also have a band H - can I
include an extra ELSE statement to accommodate this within the first
IF? I tried to do this but when I compiled it the error message said
it expected another IF.

Cheers
Steven

 
Reply With Quote
 
Bob Quintal
Guest
Posts: n/a
 
      11th Feb 2011
Steve <(E-Mail Removed)> wrote in
news:2bc47704-7392-466d-9669-(E-Mail Removed)
m:

> That's very helpful Bob, thanks. What if I also have a band H -
> can I include an extra ELSE statement to accommodate this within
> the first IF? I tried to do this but when I compiled it the error
> message said it expected another IF.
>
> Cheers
> Steven
>
>


To add an extra condition you can use the ElseIF keyword for all
except the last condition.

IF Band = "F" then
if Rate = "D" then
Me.ActualFundingAmt = 22495
else ' rate must be R
Me.ActualFundingAmt = 42303
end if
ElseIf Band = "G"
if Rate = "D" then
Me.ActualFundingAmt = 32967
else
Me.ActualFundingAmt = 49069
End if
ElseIf Band = "H"
if Rate = "D" then
Me.ActualFundingAmt = 32967
else
Me.ActualFundingAmt = 49069
End if
Else ' Band = 'Z'
End if

There is also the Select Case structure, read the help on that. It's
useful if you have many possibilitiesto check in a single field

Select Case band
case 'A'
' do something,
Case 'B'
' do something different
Case else
' handle the unforseen
End Select



--
Bob Q.
PA is y I've altered my address.
 
Reply With Quote
 
Steve
Guest
Posts: n/a
 
      14th Feb 2011
The ElseIf/Else option worked fine Bob. I got in a bit of a muddle
matching the Ifs with the End Ifs but once I dealt with that it was
OK.

Thanks again for your help.

Steven
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Column automatically adjusts width to fit text entries =?Utf-8?B?cmVkc2FuZGVycw==?= Microsoft Excel New Users 7 19th Jul 2007 03:20 AM
Remember last entries in a forms text box or combo box Fletcher Microsoft Access Form Coding 4 17th Jul 2007 03:39 PM
Display combo box entries in reports as text, not ID number =?Utf-8?B?amFuZTI4MDU=?= Microsoft Access 2 28th Mar 2007 02:07 AM
automatically generating field text based on other fields Kyle Microsoft Access 2 6th Dec 2005 08:11 PM
How do I...automatically add entries to a Combo Box's associated table WGD Microsoft Access Getting Started 4 29th Jan 2004 03:32 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:15 PM.