473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Making Railway Time table in excel using combo boxes & Text Boxes

Hellow,
I am trying to make Railway time table in excel through Visual basic. I have 2 combo Boxes (From and To)& Multiple Text Boxes to populate Train No, Train Name, Arrival & departure (TextBox 1-2-3-4) respectively. When I select Combo box 1 & 2, data is populated in all cited 4 text box correctly(1-2-3-4). But in text box no. 5-6-7-8/9-10-11-12 etc are also populated the same data as appear in text box no 1-2-3-4. Coding which I create is as below.

Expand|Select|Wrap|Line Numbers
  1. 'Get Items to ComboBox2 based on ComboBox1 selection
  2. Private Sub ComboBox1_Change()
  3.  
  4.     'Variable Declaration
  5.     Dim iCnt As Integer
  6.  
  7.     'Clear Combobox2 before loading items
  8.     ComboBox2.Clear
  9.  
  10.     With ComboBox2
  11.         Select Case ComboBox1
  12.             Case "Nagpur"
  13.                 .AddItem "Ambala"
  14.                 .AddItem "Amgaon"
  15.                 .AddItem "Agra Cantt"
  16.                 .AddItem "Amravati"
  17.                 .AddItem "BADNERA JN"
  18.                 .AddItem "BADSHAHNAGAR"
  19.                 .AddItem "BADSHAHNAGAR"
  20.                 .AddItem "BAGBAHRA"
  21.  
  22.         End Select
  23.     End With
  24.  
  25. End Sub
  26.  
  27. 'Get Train No based on ComboBox2 selection
  28. Private Sub ComboBox2_Change()
  29.  
  30.     'Variable Declaration
  31.     Dim iRow As Integer
  32.     iRow = 3
  33.  
  34.     'Clear Combobox2 before loading items
  35.     TextBox1.Text = ""
  36.  
  37.     'Get Train No based on ComboBox2 selection
  38.     Do
  39.         iRow = iRow + 1
  40.     Loop Until ComboBox2.Text = Sheets("Data").Cells(iRow, 3)
  41.     TextBox1.Text = Sheets("Data").Cells(iRow, 4)
  42.     TextBox2.Text = Sheets("Data").Cells(iRow, 5)
  43.     TextBox3.Text = Sheets("Data").Cells(iRow, 6)
  44.     TextBox4.Text = Sheets("Data").Cells(iRow, 7)
  45.     TextBox5.Text = Sheets("Data").Cells(iRow, 4)
  46.     TextBox6.Text = Sheets("Data").Cells(iRow, 5)
  47.     TextBox7.Text = Sheets("Data").Cells(iRow, 6)
  48.     TextBox8.Text = Sheets("Data").Cells(iRow, 7)
  49.  
  50. End Sub
  51. Private Sub TextBox1_Change()
  52. End Sub
  53. Private Sub TextBox2_Change()
  54. End Sub
  55. Private Sub TextBox3_Change()
  56. End Sub
  57. Private Sub TextBox4_Change()
  58. End Sub
  59. Private Sub TextBox5_Change()
  60. End Sub
  61. Private Sub TextBox6_Change()
  62. End Sub
  63. Private Sub TextBox7_Chnge()
  64. End Sub
  65. Private Sub TextBox8_Change()
  66. End
Request you kindly help. Thanks for your active co-operation.
Regards,
Bhawesh
Dec 17 '14 #1
1 1983
twinnyfo
3,653 Expert Mod 2GB
Bhawesh,

Lines 45-48 of your code block above is assigning the values from Columns 4-7 (which are the same values assigned to Text Boxes 1-4). Perhaps you meant to assign columns 8-11?

Also, I see no references in your Code to Text Boxes 9-12, so I am not sure how they are getting updated.

Just as a side note, Lines 11-22 could get quite cumbersome as you add more and more Departure/Destination cities. Have you thought of having this data elsewhere on the Spreadsheet?

Better yet, have you thought of creating an MS Access Database? (yeah, that's just a personal plug, since that is more of my forte)
Dec 17 '14 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Steve Zifah | last post by:
Im just a beginner using MS Access 2002. I have a database set up with only 1 table and need help searching the database. I would like the search to be similar to a web search interface. I...
3
by: Paul | last post by:
I have some option boxes and combo boxes that looks up values on a separate table (i.e. campus table with campusID & campus name fields) When I choose a selection from the combo box, it puts the...
7
by: Aravind | last post by:
Hi folks. I have 2 forms, frmBorrow and frmHistory frmBorrow has an unbound multi-column combo box (cboMember) and 7 unbound text boxes (MemNo, MemName, MemIC, MemType, CourseFaculty, Borrow,...
3
by: Brian Mitchell | last post by:
Hello, I have a weird problem with my Visual Basic. The text in list boxes, buttons and message boxes are missing when I run the program. Everything looks fine at design time but somewhere when I...
3
by: winky10 | last post by:
From a newbie. MSAccess 2000. I have a form with checkboxes and text boxes bound to their respective fields in a table. Using a query, I am able to create a report based on those checked boxes. ...
0
by: janbazamin | last post by:
Hi Dear. I am making time table application in ASP.NET i am facing some problem i am adding Start time, End Time In Database. on some date. if i again select same date and stat time and end time. i...
2
by: jw01 | last post by:
I have a form in which there is one combo box and three text boxes: Combo Box: -> Item A -> Item B -> Item C TextBox1: TextBox2: ...
2
by: chaosdl | last post by:
Hello, I am currently using Visual Basic 2005 express edition with a MS Access database. I have made a "Contacts" Form, where the user will be able to enter a members surname and press an OK...
9
by: Marianne160 | last post by:
Hi, I know there are various answers to this problem available on the web but none of them seem to work for me. I am using Access 2003 to make a form to look up data from a table. I have so far...
4
by: Denielle | last post by:
Currently I have a form that has bound text boxes and combo boxes on it. Some of the combo boxes are pulling the information from other tables and some are manually entered in. I would like to...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.