?
Solved

MS Access 2010 form field value based on another field value

Posted on 2013-02-06
3
Medium Priority
?
690 Views
Last Modified: 2013-02-06
i have a field called "steps" (combo box) and another called "percencomplete" (text box) in a table. On a form I want the value in the "percencomplete" to autopopulate based on what is chosen in the "steps" (called cbosteps on the form) field upon update. So I have created a table that has a column of all the values that would possibly be in the "steps" field (field name= Stepname) with another column of corresponding percentage values that are intended for the "percencomplete" field (field named also percencomplete).  I named it "tblALLSTEPS".  Then I tried ;

Private Sub cboStep_AfterUpdate()
   On Error Resume Next
   PercenComplete.RowSource = "Select tblALLSTEPS.percencomplete " & _
            "FROM tblALLSTEPS " & _
            "WHERE tblALLSTEPS.stepname = '" & cboStep.Value & "' " & _
            "ORDER BY tblALLSTEPS.percencomplete;"
End Sub

It didn't work. Any ideas how to make it work?
0
Comment
Question by:JoeMommasMomma
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 38861792
(1)
Eyeball the row source of your Steps combo box, and make sure the value that ultimately goes into percentcomplete is in there.  You can make it invisible if you want by making sure the ColumNWidths number for that column is zero.

For example, say this is the 5th column.

(2)
In the AfterUpdate event of cboSteps, write VBA code that goes something like this:

Private Sub cbosteps_AfterUpdate()
Me.percentcomplete = Me.cboSteps.column(4)
End Sub

Note that the 4 value is base-zero, so the 5th column means a 4 goes here.
0
 
LVL 26

Accepted Solution

by:
jerryb30 earned 2000 total points
ID: 38861827
I assume you only have one record percentcomplete for any one stepname

me.percentcomplete = dlookup("percentComplete", "tblAllSteps", "stepName = '" & me.cboStep & "'")
0
 

Author Closing Comment

by:JoeMommasMomma
ID: 38861932
thanks so much
0

Featured Post

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question