Form Automation

  • Thread starter pushrodengine via AccessMonster.com
  • Start date
P

pushrodengine via AccessMonster.com

In need a code that will move the value of a text box to another text box
when a specific value is entered into a combo box.

When “Place 1â€, “Place 2â€, “Place 3†or “Place 4†is select from the
“Location†combo box, the form will automatically input the value of Textbox
“Distance†into Textbox “Coverageâ€.

Thank You
 
R

ruralguy via AccessMonster.com

You can use the AfterUpdate event of the ComboBox to set the two TextBoxes
the same with:
Me.Coverage = Me.Distance
...and you can use a Select Case to determine when to execute the code.
 
P

pushrodengine via AccessMonster.com

How do I use Select Case excute:

Me.Coverage = Me.Distance

when “Place 1â€, “Place 2â€, “Place 3†or “Place 4†is select from the
“Location†combo box, the form will automatically input the value of Textbox
“Distance†into Textbox “Coverage�

Thanks
 
A

Albert D. Kallal

pushrodengine via AccessMonster.com said:
How do I use Select Case excute:

I don't believe you need a select case in this situation at all.

What you do is build your combo box based on a table with the two collums of
data. (in fact I suspect that this point in time to, boxes likely based on
the table, and thus you wanna pull the additional column into another text
box on the form.

collum 1them to columns of data

So, assuming your combo box has two collums like:

Place distance

Place 1 20
Place 2 30
Place 3 40
Place 4 50

In the after update event of the combo box, you simply go:

me.Distance = me.MyComboBox.column(1)

the note that the column function is zero based, and thus zero means the
first column

Thus, you only need one line of code to do this whole job .....
 
R

ruralguy via AccessMonster.com

In case you *do* need a Select Case then:

--------------------------------------------------
Private Sub Location_AfterUpdate()

Select Case Me.Location
Case "Place 1"
Me.Coverage = Me.Distance
Case "Place 2"
Me.Coverage = Me.Distance
Case "Place 3"
Me.Coverage = Me.Distance
Case "Place 4"
Me.Coverage = Me.Distance
Case Else
'-- Do Nothing!!
End Select

End Sub
-------------------------------------------------
 
P

pushrodengine via AccessMonster.com

The code works great, but is there a way to make...
_________________________________________________
Select Case Me.Location
Case "Place 1"
Me.Coverage = Me.Distance
Case "Place 2"
Me.Coverage = Me.Distance
Case "Place 3"
Me.Coverage = Me.Distance
Case "Place 4"
Me.Coverage = Me.Distance
Case Else
'-- Do Nothing!!
End Select

End Sub
__________________________________________________

...part of my Add Incident Button On Click code below:

__________________________________________________
Private Sub AddIncident_Click()
On Error GoTo Err_AddIncident_Click
Me!chkOKToClose = True
DoCmd.GoToRecord , , acNewRec

Exit_AddIncident_Click:
Exit Sub

Err_AddIncident_Click:
MsgBox Err.Description
Resume Exit_AddIncident_Click
End Sub
____________________________________________________

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top