473,554 Members | 2,872 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to give an SQL statement in combobox(Visual basic 6.0)

58 New Member
Hi everyone..

I want to insert a combobox with the list of test names of a database, but the testname contains 15000+ data, and I cant type all the data. so can any one help me in writing an SQL statement, so that if I give that statement it will automatically swaps the table names to the combobox.

P.S I know the SQL statement but I dono where to give that SQL statement in combobox

explanation with program will be verymuch helpfull for me

Thanks in advance

Mar 31 '09 #1
5 6061
8,127 Recognized Expert Expert
you just need to go 1...2...3

1.Create a connection
2. open the recordset
3. in a loop add the items from recordset to combobox.
Mar 31 '09 #2
58 New Member
haaa....I am totally new to Visual basic....I am not able to understand what you are telling...can you explain in detail...plzz.. .I have done some program to extract the data...in the program if you look at the SQL statement(under lined) I want to insert all the values of fullname into the combo box, so that if I select one of the fullname then the data regarding that fullname should be extracted and should be displayed after pressing the Ok button

Private Sub Okbutton_Click( )
On Error Resume Next

Dim sConnect As String
Dim db As Database
Dim rs As Recordset
Dim Ws As Workspace
'Dim ID As Double
'Dim doubleID1 As Double
Dim intstring As String

Set Ws = DBEngine.Worksp aces(0)

sConnect = "ODBC;DSN=WinUT MS_RT_DB;UID=Lo calhost;PWD=;Da tabase=WinUTMS_ RT_DB;"

Set db = Ws.OpenDatabase ("", 0, 0, sConnect)

Set rs = db.OpenRecordse t("SELECT Fullname FROM abssubtest")
Do While Not rs.EOF
'ID = rs!Messwert
'doubleID1 = rs!UPLimWert
intstring = rs.Fields("Full name")
End Sub
Mar 31 '09 #3
75 New Member
I have made some changes to your loop....

Expand|Select|Wrap|Line Numbers
  1. Do While Not rs.EOF
  2. 'ID = rs!Messwert
  3. 'doubleID1 = rs!UPLimWert
  4. combo1.add (rs.Fields("Fullname"))
  5. rs.MoveNext
  6. Loop
  7. End Sub
Apr 4 '09 #4
58 New Member
Private Sub Combo1_Click()

Label1.Caption = "find" & Combo1.Text
Label1.Visible = True

End Sub

Private Sub Form_Load()
On Error Resume Next

Label1.Visible = False
DataGrid1.Visis ble = False

Dim cn As ADODB.Connectio n
Dim rs As ADODB.Recordset

Set cn = New ADODB.Connectio n
cn.ConnectionSt ring = "ODBC;DSN=WinUT MS_RT_DB;UID=Lo calhost;PWD=;Da tabas e=WinUTMS_RT_DB ;"

Set rs = New ADODB.Recordset
rs.Open "absprfg", cn, adOpenKeyset, adLockPessimist ic, adCmdTable

Do While Not rs.EOF
Combo1.AddItem rs.Fields("Modu s")
If Not (rs.EOF And rs.BOF) Then
End If
End Sub
Private Sub Command1_Click( )
On Error Resume Next
Me.Form.RecordS ource = "SELECT Fullname FROM abssubtest & ComboBox.Value & " ';"

End Sub

Private Sub Label1_Click()
DataGrid1.Visib le = True

Adodc1.CommandT ype = adCmdText
Adodc1.RecordSo urce = "select absprfg.Modus From absprfg WHERE absprfg.Modus=' " & Combo1.Text & "' "

End Sub
I have done the above program..but after pressing the run button..I am getting the blank screen and after some time the vb is not responding and I have to close the program...even I have seen it with break point but of no use....can you please tell me where I have done the mistake...

Apr 6 '09 #5
75 New Member
I think at this line your are having problem.
Expand|Select|Wrap|Line Numbers
  1. Me.Form.RecordSource = "SELECT Fullname FROM abssubtest & ComboBox.Value & " ';"
Apr 6 '09 #6

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

Similar topics

by: Tech | last post by:
In Visual Basic 6.0, the Locked property of a ComboBox control determined whether the text-box portion of the control could be edited. In Visual Basic ..NET, the Locked property prevents a control from being moved at design time. There is no direct equivalent for the Visual Basic 6.0 Locked property. What to do next Change the...
by: Steffen Laser | last post by:
Hi group, I have a problem that I already have posted to the german C# newsgroup. Since nobody could help me there, I'd like to try it here again: I set the selected item of a combobox like this: myCombo.SelectedItem = 3; But after that the ComboBox displays only the first entry of the list. When I add the line
by: jaYPee | last post by:
i have successfully added a combobox control in datagrid. this is the code i have created but don't show up the record from another table. Private Sub AddCustomDataTableStyle() Dim ts1 As DataGridTableStyle ts1 = New DataGridTableStyle() ts1.MappingName = "SchYrSemCourseJoin" ' Set other properties. ts1.AlternatingBackColor =...
by: Juan Pedro Gonzalez | last post by:
I wanted to add a Combobox to a toolbar... Kind of the look you get on VisualStudio's toolbar. I've been able to find some VB 6 samples, but the placeholder option is no longer available for ToolbarButtons... Does anyone know how this could be done? Looking forward to hear from you,
by: paul c | last post by:
Apologies if I'm sending this to the wrong group. If so I'd be grateful if somebody could point me to the right one. I'm using microsoft visual c++ 6.0 compiler. My code is C, I just use the c++ compiler for easier positioning of declarations here and there. I am putting together a small interpreter that will do a great deal of...
by: news.microsoft.com | last post by:
I am new to this so bear with me. I have a set of combo boxes. Lets call them ComboBox1 and ComboBox2. ComboBox1 items are pulled from a table. When a user selects a certain item I want to disable ComboBox2. i can make this work in Visual Web Developer, but have been unsuccessful in Visual Basic 2005.
by: marknoten | last post by:
I'm quite a newbie to Visual Basic and have a problem with the Input # statement in the Visual Basic Editor from Excel. I would like to read in a tab delimeted text file selected by a user with records like this: <snip> O 21.266 17.733 28.155 N 20.649 17.703 30.320 C 20.883 17.336 31.723 </snip> I'm using the code below to read each line...
by: evlpupy | last post by:
Good Afternoon I have need of assistance for programming a visual basic form in excel. In excel I have 3 named ranges TM Agents1 Agents2 In the TM range I have 5 different names of managers (ie Tom Smith, Bob Green, etc.)
by: Bruno43 | last post by:
Hi I have a question about the Combo Box This is the only Code I have seemed to be able to find to add items to a Combo Box... Is there a way to modify it or another command that I could use to have my own index or value inserted, but display the text NewField Me.evSelectName.Items.Add("NewField") So that when the click 'NewField' the...
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.