Solved

Combobox display selection on cliking

Posted on 2002-03-26
7
307 Views
Last Modified: 2010-05-02
kcm,i try to include the reference to the database,and it worked,it was able to display the items plus the selction of the combo box items,but when i click on the next and previous buttons ,it displays tiext instead of values on the textbox.
0
Comment
Question by:humbk2002
7 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6896142
You don't need to reopen the database and recordset, if you do then the movenext will not have any effect:

Private Sub NextBtn_Click()
Set DB = OpenDatabase("Z:\Project\FinalProject(ExpensesMonitoringSystem).mdb")
Set RS = DB.OpenRecordset("Expense Category")

Remove these lines and try again.
0
 
LVL 44

Expert Comment

by:Arthur_Wood
ID: 6896218
you are setting Text4 to be values in the recordset fields, but ONLY THE LAST value is actually the one that will be displayed.  Each time you assign a value to a texctbox, THAT value REPLACES (completely replaces) whatever value was there before.

from this code:

Private Sub Form_Load()
Set DB = OpenDatabase("Z:\Project\FinalProject(ExpensesMonitoringSystem).mdb")
Set RS = DB.OpenRecordset("Expense Category")
Combo1.AddItem "Telephone Bills"
Combo1.AddItem "Transportation"
Combo1.AddItem "Electricity Bills"
Combo1.AddItem "Payroll Bills"
Combo1.AddItem "Stationery"
Text4.Text = RS!Payroll
Text4.Text = RS!TelephoneBill
Text4.Text = RS!Transportation
Text4.Text = RS!ElectricityBill
Text4.Text = RS!Stationery
Call List1.AddItem("Date : " & Date)
Call List1.AddItem("Time : " & Time)
End Sub


Text4 will end up with ONLY the value from

Text4.Text = RS!Stationery

the preceding 4 lines are TOTALLY USELESS, and accomplish ABSOLUTELY nothing.

What are you trying to show in Text4? (by the way, it is a very GOOD idea to name text boxes for what they are REALLY showing, rather than to use the default name that Access assigns to them. So is Text4 showing an Amount?, then name it txtAmount.  That way you program has some sembelance of readability, and you do not need to remember what Text4 is used for.)

0
 
LVL 5

Expert Comment

by:kcm76
ID: 6896387
HI humbk2k2


pls Try out this code
open the Recordset in the Formload event.
DO NOT REOPEN IT AGAIN IN CMD_NEXT OR CMD_PREV event.

Dim strFldName as String

Private Sub Form_Load()
Set DB = OpenDatabase("Z:\Project\FinalProject(ExpensesMonitoringSystem).mdb")
Set RS = DB.OpenRecordset("Expense Category")
Combo1.AddItem "Telephone Bills"
Combo1.AddItem "Transportation"
Combo1.AddItem "Electricity Bills"
Combo1.AddItem "Payroll Bills"
Combo1.AddItem "Stationery
End Sub


Private Sub Combo1_Click()
strFldName = Combo1.List(Combo1.ListIndex)
Text4.Text = FillTextValue(strFldName)
End Sub

Private Sub cmdPrev_Click()
if not rs.BOF then
  rs.MoveNext
  text4.Text = strFldName
else
  Msgbox "Beginning of File reached"
end if
End Sub



Private Sub cmdNext_Click()
if not rs.EOF then
  rs.MoveNext
  text4.Text = strFldName
else
  Msgbox "End of File reached"
end if
End Sub


Private Function FillTextValue(strVal as String) as String
Select Case strVal
    Case "Telephone Bills"
        FillTextValue = rs("TelephoneBill")
    Case "Transportation"
        FillTextValue = rs("Transportation")
    Case "Electricity Bills"
        FillTextValue = rs("ElectricityBill")
End Select
End function

ALL THE BEST

KCM
0
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

Author Comment

by:humbk2002
ID: 6898808
kcm76,your code there is an error message thats displayed when i try to make a selection on the combo box items.
There is a compilation error thus:

"ByRef argument type mismatch.:

Remember i want to get the infomation to be displayed on the textbox to come from a database,and the figure to be displayed on the textbox(text4),has to be displayed whenever i make a selection on the combobox,afters selecting,the next button and the previous buttons should allow me to go from one item to another on the list.
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 7017042
10 open questions, many are far below the minimum for easy questions of 50 points.  The maximum per question is 500 points.  ADMINISTRATION WILL BE CONTACTING YOU SHORTLY.  Moderators Computer101, Netminder or Mindphaser will return to finalize these if they are still open in 7 days.  Experts, please post closing recommendations before that time.

Below are your open questions as of today.  Questions which have been inactive for 21 days or longer are considered to be abandoned and for those, your options are:
1. Accept a Comment As Answer (use the button next to the Expert's name).
2. Close the question if the information was not useful to you, but may help others. You must tell the participants why you wish to do this, and allow for Expert response.  This choice will include a refund to you, and will move this question to our PAQ (Previously Asked Question) database.  If you found information outside this question thread, please add it.
3. Ask Community Support to help split points between participating experts, or just comment here with details and we'll respond with the process.
4. Delete the question (if it has no potential value for others).
   --> Post comments for expert of your intention to delete and why
   --> YOU CANNOT DELETE A QUESTION with comments; special handling by a Moderator is required.

For special handling needs, please post a zero point question in the link below and include the URL (question QID/link) that it regards with details.
http://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
 
Please click this link for Help Desk, Guidelines/Member Agreement and the Question/Answer process.  http://www.experts-exchange.com/jsp/cmtyHelpDesk.jsp

Click you Member Profile to view your question history and please keep them updated. If you are a KnowledgePro user, use the Power Search option to find them.  

Questions which are LOCKED with a Proposed Answer but do not help you, should be rejected with comments added.  When you grade the question less than an A, please comment as to why.  This helps all involved, as well as others who may access this item in the future.  PLEASE DO NOT AWARD POINTS TO ME.

To view your open questions, please click the following link(s) and keep them all current with updates.
http://www.experts-exchange.com/questions/Q.20283897.html
http://www.experts-exchange.com/questions/Q.20273817.html
http://www.experts-exchange.com/questions/Q.20274315.html
http://www.experts-exchange.com/questions/Q.20275778.html
http://www.experts-exchange.com/questions/Q.20277334.html
http://www.experts-exchange.com/questions/Q.20278207.html
http://www.experts-exchange.com/questions/Q.20281536.html
http://www.experts-exchange.com/questions/Q.20284857.html
http://www.experts-exchange.com/questions/Q.20285984.html
http://www.experts-exchange.com/questions/Q.20287484.html



*****  E X P E R T S    P L E A S E  ******  Leave your closing recommendations.
If you are interested in the cleanup effort, please click this link
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=commspt&qid=20274643 
POINTS FOR EXPERTS awaiting comments are listed in the link below
http://www.experts-exchange.com/commspt/Q.20277028.html
 
Moderators will finalize this question if in @7 days Asker has not responded.  This will be moved to the PAQ (Previously Asked Questions) at zero points, deleted or awarded.
 
Thanks everyone.
Moondancer
Moderator @ Experts Exchange
0
 
LVL 16

Expert Comment

by:twalgrave
ID: 7754732
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in Community Support that this question is:
- refund/PAQ
Please leave any comments here within the
next seven days.
0
 

Accepted Solution

by:
SpideyMod earned 0 total points
ID: 7811556
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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