Displaying Results From A SQL Query In Listbox
I have a VB6 Project that is working fine as it is, but need to enhace it's features by adding a listbox to show what records in the Access database will be updated from the query that I have written, just so the client can make note of what is being updated. Right now, you click UPDATE and the records are updated but with no notification of which ones or how many. I just need to know the way to make the listbox show the records that are being updated and to make a popup say how many were updated.
The following is the code that I have for my "UPDATE" command button:
Private Sub cmdUpdate_Click()
On Error Resume Next Dim con As ADODB.Connection Dim strSQL Set con = New ADODB.Connection Err.Clear con.Open ("Provider=microsoft.jet.OLEDB.4.0;Data Source=C:db1.mdb") If Err = 0 Then strSQL = "UPDATE MWCAS SET [Referral Source] = '" + cboSource.Text + "' WHERE [Referring Provider] = '" + cboProvider.Text + "';" Err = 0 con.Execute strSQL If Err <> 0 Then MsgBox Err.Description End If
End If End Sub
If more information is needed, please let me know. Thank you guys for any help that you can give.
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Displaying Query Results In VB App
I have a db of patients. When placing a new booking for a patient, I would like to be able to search existing records and populate the fields based on existing info if a record is found. I can create the code and queries to search by a few different criteria (we'll say last name for my question).
My question being, what are some ways to present the results? Datagrids or flexgrids are one option, but I would like the user to be able to click on the name (if there is more than one Smith for example) and have that name/address populate the fields and I am not sure if you can do that with the grids. Any suggestions would be greatly appreciated.
Cheers
Displaying Query Results In VB App
I have a db of patients. When placing a new booking for a patient, I would like to be able to search existing records and populate the fields based on existing info if a record is found. I can create the code and queries to search by a few different criteria (we'll say last name for my question).
My question being, what are some ways to present the results? Datagrids or flexgrids are one option, but I would like the user to be able to click on the name (if there is more than one Smith for example) and have that name/address populate the fields and I am not sure if you can do that with the grids. Any suggestions would be greatly appreciated.
Cheers
Displaying Query Results
I'm running a query from a Access Database file, and I'm trying to print out the results. Anyone know how to do this? thanks
Displaying Query Results In A Form
I am currently working on a database in Access. I have set up a few queries and want to link them to one form...
For instance, I have 3 forms with queries attached so that when I click a button on each form, it does a different query. However, I also have a results form and I want the results of the query to be displayed on this form, regardless of which query I run.
Can anyone help? If you need more details, just ask.
Access Query/Displaying Sum Results In App
What i'm trying to is run a query from an Access db and display the sum results within an app in VB.
Then i will have option to export the full info out to an excel file but that part i think i can do thanks to RobDog888 and BrianHawley.
Any thoughts/suggestions/examples?
Thanks
All Fields Not Displaying In Query Results
Hi,
I have a query which comes from 4 joint tables. The query result is not showing all the fields that i have selected to show. It is missing about 10 fields that are all from one table. If i select one of the missing fields again in the query design grid then that field displays with the name "Expr1001". what could be the reason??? Please help.
Thanks!
Displaying Results From A Crosstab Query
Hey thanks for the help on creating a new table. it works great. My other problem is displaying results from a crosstab query. I figured out how to create a crosstab query and it works really well, but I can't figure out how to display the results, or how to store the results in variables for later usage. Any help would be appreciated. Thanks again for the help!!
Displaying Results In ListBox
I am having problems listing my results in a list box. I enter in search criteria for a name and it brings back 25 results, but only displays one name in the listbox. I am looping through the search, but is there a property setting on the list box so I can display all the results?
UPDATE QUERY PROBLEM - Displaying Results
Hi
I've been running ADO update queries, wherby an ID is selected and the results are displayed ready for updating. I have found that if I use a scrolling text box, then all of the text is brought back, i.e. more than just one word, however when I use a normal text box, only the first word is brought back. This is a problem for me, because when someone enters the e.g street address, you will usually have 3 strings.
Is there anything I can do with this.
My code looks as follows: - (obviously I haven't included the whole lot)
'***********************************************************
'* Step 2: Display the form for editing a club
'***********************************************************
ElseIf Request.Form("FormAction") = "Step2" Then
'Create the recordset object
Set objRS = Server.CreateObject("ADODB.Recordset")
'Set the SQL string
strSQL = "Select * from Student_Details Where Login = '" & _
Request.Form("cboLogins") & "'"
'Open the recordset getting the club details for this club
objRS.Open strSQL,"dsn=PTRAINING"
%>
<form action=../ExternalStudents/confirmupdatefinaldetails.asp method=post name=frmUpdate>
<input type=hidden name=Action value=Update>
<input type=hidden name=txtyeardate
value=<%=Request.Form("cboLogins")%>>
<table width="737">
<tr>
<td width="253" colspan="2"><font face="Arial" size="2">Login: <font color=navy><%=Request.Form("txtLogin")%></font></font></td>
<td width=62></td>
<td width=450></td>
<td width="32"></td>
</tr>
<tr>
<td nowrap width="253" colspan="2"></td>
<td nowrap width="519" colspan="2"></td>
<tr>
<td nowrap width="253" colspan="2"><u><font face="Arial" size="2" color="#000080">COMPANY DETAILS</font></u></td>
<td nowrap width="519" colspan="2"><font color="#000080" size="2" face="Arial">
<u>COMPANY SUPERVISOR</u>
</font></td>
<td nowrap width="72"></td>
<td width="181"></td>
<td nowrap width="35"><font face="Arial" size="2">Address1</font></td>
<td width="484"><font face="Arial" size="2"><input type=text name=txtCompany_Address1 size=24
value=<%=objRS("Company_Address1")%>></font></td>
<tr>
<td nowrap width="72"></td>
<td width="181"></td>
<td nowrap width="35"><font face="Arial" size="2">Address2</font></td>
<td width="484"><font face="Arial" size="2"><input type=text name=txtCompany_Address2 size=24
value=<%=objRS("Company_Address2")%>></font></td>
</table>
</form>
<%
'Close and dereference database objects
objRS.Close
Set objRS = Nothing
End If'End If for step processing
%>
<p style="margin-left: 200"><a href="../HomePage/Externalstudents.asp"><font face="Arial" size="2">Back to
External Students Main Page</font></a></p>
</BODY>
</HTML>
Populating A Listbox With A Results From A Query
Hi,
I am trying to send the results of a query to a listbox on the same form. I am using VB6 and an access database. I am using this code:
<vbcode>
private sub cmdListResults
Dim T As Recordset
Data1.Refresh
For Each T In Data1.Database.Recordsets
List1.AddItem T.??????
Next
endsub
</vbcode>
I don't know which property to use with the T. I have tried a few but get no results returned in the listbox. Am I even on the right track?
Thank you,
Sandy
Load Query Results To List In ComboBox Or ListBox
I have a problem which I think must be simple to solve, but cannot find the answer anywhere obvious...
I have a stored query on an Access Database, which uses SELECT DISTINCT to find all currently-used values for a particular field. My aim is to display the results of this query in a combo box (and in another case, a list box) so the user can simply pick what s/he wants.
Is there a direct way to load the values in, or does it involve loading to arrays or something? I am using the ADO Data Environment to access the database.
Continue Asking The Experts About "displaying Results From A Crosstab Query "
It's great to find the topic "displaying results from a crosstab query" posted sometime ago. It can solve the problem with crosstab query that I stucked on quite a long time. But I still have one more problem: How about a crosstab query with parameters? SQL experts, please help
Thanks a lot in advance,
Viet
Displaying Results
hey i'm doing a school project so i am using vb for the first time. so please put things simply for me
i am writing a program where someone fills in different marks out of one hundred for three subjects. i then need to be able to click a button and have the results displayed (in Grade form, A, B, C, U) i need them to be in asending order in one place, not in three sperate boxes ( for maths english and science)
thanks
Rammstein
Displaying Results
Hello,
i have created a form by wich the user can specify what data they wish to query and how they wish to sort the data and what attributes to view in the final view.
when i click the button it connects to the database then runs the SQL to get the specified data.
how do i display this data??
somebody has recomended to me data grid commponent, but can this be used to show three different types of view?
i need to be able to display, single record view, multiple record view, or parent child view!
can someone please help me?
they can make up the connecting part of the code as i understand that far!!
thank you,
Rob
Displaying My Results
when i click a button on form1, it generates a connection to the database and runs an sql to collect the record set.
my next problem is trying to display this information, i have been asked to let the user view the results in the following,
single records,
multiple records,
or parent child.
can anyone please help me? i dont know how to get the information to be shown.
thank you,
rob
Displaying Results From DOS
Does anyone know how I can display results from a DOS based program in a text box? The particular program I am trying to run does not allow you to send the results to a log file that I could then read into the text box. Ideally I simply be able to display the DOS window in my app somehow???
Displaying Results
I want to display a log of some websites visited. What could I store the log in? I need to display the date, website, and another short string and the results need to be easily read back into the control when the program opens again. What could I use?
Displaying Search Results - Help!
Hi, I have written a video retrieval program which allows a user to search an Access database for video annotations. The program uses a data control and an SQL statement.
The program works but I am not happy with the way it displays the results.
First I connected a series of text boxes and added scrolling functionality (FindNext / FindPrevious) but I want to list all results for the user to see at once.
Next I tried using a datagrid which was better but one of my database fields is quite long and it wont fit onto one form (As far as I can see there is no way of using multiline) and it is difficult to navigate the results.
Is there a better way of listing my results? What I would really like is to dynamically list all returned records with an option button for each so that the user can select the video segment to play.
I am new to this forum but would really appreciate any advice.
Thanks
Monkey_Magic
Displaying Results On A New Form???
hello, i am fairly new to databases and visual basic. i am doing a project where i have a main form and a second form. i want the users to be able click on a command button on the main form, this will filter out the right records from a database and the results will be displayed on a new form allowing the users to edit and add details to the records. for example, the database is a list of students and what class they are in, if the teacher clicks on 'art class1' then the details of the students in that class will shown on a new form. first i would like to know i this is possible and if so how do i go about doing it?
Displaying Results In Form
Hey guys, new day new problems.
Ive been looking through all my books and cant find how to print the results to a text box in a form.
First Question) What is the command to print to a form (not a actual printer with ink) kinda like this:
Code:
function multi ()
dim a as integer
a = 0
a= 5*2^2
print a
end function
2nd Q) How do you call the function that you want to print after someone clicks a command button and then display it the results in a text box?
Thanks for your help guys, still new to the coding world.
Displaying Results From Excel To VB..help!
Hi,
I am designing an interface using VB to display the results from an Excel spreadsheet. I wish to know if it's possible to display results in 'table' form, as when it retrieves from the MS Access. Do I use Flexgrid or other components?
I do not wish to display the whole Excel spreadsheet workbook altogether, just selected tables frm Excel.
Please help.
Thanks!
Displaying Search Results
hi everyone...
I have a big problem with my VB project that I'm doing now...
first of all I'm doing a very basic database entery for a call center...to record the clients information that we speak with, so I made a form with text entery (mostly like name, phone numbers...etc)
my programme saves perfectly to the database file.
my problem is in searching. I used this code for searching :
Code:
Data1.RecordSource = "SELECT * FROM tblTransaction WHERE NomM = '*" & txtMNom.Text & "*' or TelMaison = '" & mtxtTelMaison.Text & "'"
Data1.Refresh
the problem is that it does'nt work and I get nothing, all I get is that my form clears up
now what I realy would love to do is that I need to know the best way of displaying a list of results after a search has been performed.
As my application matches records to my search criteria, I would like to list these in a List Box that I have already created and called "lstSearch" and the results should be listed by date "txtDate" so that I can choose from the date and when I press on that date it would fill in my form.
is this possible to do or am I dreaming?
thanks in advance...
peace to all...
Displaying Web Page Results
I want to create a program in VB where you can look at the information on a web page. Like a program where it displays the current news articles on a website and u can read them. And when the news on the page changes, the news in the program changes because it is reading off the webpage. Maybe with servers? Display stuff from MySQL databases? I'm sure the web page has to be set up for this which is easy, but how do i get the program to display the information from a web page? I'm new to VB, but not new to programming. Any help would be appreciated.
-Richard
Displaying Search Results
hi everyone...
I have a big problem with my VB project that I'm doing now...
first of all I'm doing a very basic database entery for a call center...to record the clients information that we speak with, so I made a form with text entery (mostly like name, phone numbers...etc)
my programme saves perfectly to the database file.
my problem is in searching. I used this code for searching :
Code:
Data1.RecordSource = "SELECT * FROM tblTransaction WHERE NomM = '*" & txtMNom.Text & "*' or TelMaison = '" & mtxtTelMaison.Text & "'"
Data1.Refresh
the problem is that it does'nt work and I get nothing, all I get is that my form clears up
now what I realy would love to do is that I need to know the best way of displaying a list of results after a search has been performed.
As my application matches records to my search criteria, I would like to list these in a List Box that I have already created and called "lstSearch" and the results should be listed by date "txtDate" so that I can choose from the date and when I press on that date it would fill in my form.
is this possible to do or am I dreaming?
thanks in advance...
peace to all...
Displaying Search Results
Hey, I am writting a simple database program for a friend's business and I have set up a search form and I have essentially "split" the screen in half and on one half is where you enter in the search information and the other half is where the results are displayed. I am using a MSAcess database and it has to be able to display multiple results but the user also has to be able to click on each of the results and be taken to the full record. My problem is I don't know how to handle the fact that there could be an indefinate amount of results to display and link each to the individual record. I appreciate any help someone could give me.
Displaying Results Within A Text Box
I need help displaying the results of my variables within a text box. Basically, I need to be able to display 3 variables within a text box.
Basically, I can get the output what I want, and the content is perfect, but the alignment is the problem.
I've tried vbTab and vbCrlf and the formatting isn't right.
What I'm trying to do is to take the DATE from DateResults and put it on the SAME LINE as the Results from Domain 1 and Domain 2. Then for the next file, it will display on the next line.
Below is what I have so far. As of right now, the date gets displayed on the top of the text box and the results gets displayed on the bottom -- I want to merge the two.
thanks for your help
'Searching for Date/Time/Year statistics
Dim varWhen As String
varWhen = InStr(1, strContent, 28)
Dim DateResults As String
DateResults = InStr(1, strContent, "Tue")
Dim strWhen, strDateDisplay As String
strWhen = strContent
strDateDisplay = Mid(strContent, DateResults, 28)
'MsgBox strDateDisplay
'Searching for Number of Connections in Domain 1
Dim Results As Integer
Results = InStr(1, strContent, ">")
'MsgBox (Results) (for use when figuring out what character position the > is in)
Dim strVar, strSearch As String
strVar = strContent
strSearch = Mid(strContent, Results + 2, 3)
'Display the results of search for Domain 1
txtResults.Text = strDateDisplay & vbTab & txtResults.Text & Int(strSearch)
'Searching for Number of Connections in Domain 2
Results = InStr(Results + 1, strContent, ">")
strSearch = Int(Mid(strContent, Results + 2, 3))
'Display the results of search for Domain 2
txtResults.Text = strDateDisplay & vbTab & txtResults.Text & vbTab & strSearch & vbCrLf
'Display the last selected file in the txtFileContent textbox
txtFileContent.Text = strContent
Displaying Set Of Calculation Results LIVE..
Hi Folks,
I would like to display my results calculated in one form (frmMain) and display them LIVE on another(frmDisplay).The display will be in the form of populating text boxes and as X-Y graph showing X versus Y while the calculations are running in the background.Is this possible with VB.
Any help or suggestion would be appreciated.
Kind regards,
Hudai
Searching A Database && Displaying Results
Hey,
I am currently making a program that is connected to an Access database.
The problem is, I am trying to make the database searchable, so that it will display the results as another sort of database with buttons to click for next and that sort of stuff.
How do I...:
a) Search a database, and...
b) Display the results as a database?
I know how to code the buttons for swapping between records and that sort of stuff, I just can't figure out the above questions.
Could anyone either direct me to some sites that could help me with my problem, or tell me how to do it?
Thanks,
Fiona
Searching Database And Displaying Results
I have an ms acess database setup using adodc1 in the form.
I have a text box to enter in text I want to search and a command button to execute the search. I want the results to display in a listbox.
Can't figure out how to get the results to display.
Displaying Search Results In Datagrid
hi all i'm supposed to get results from a database and show them on a datagrid using a search button. will my code work? and any way to improve on it? comments pls....
Dim ds As DataSet
Dim dr As DataRow
Dim myConnection As New SqlClient.SqlConnection
Dim myCommand As New SqlClient.SqlCommand
Dim adapter As New SqlDataAdapter
DataGrid.Visible = True
ds = New DataSet
adapter.SelectCommand = myCommand
adapter.SelectCommand.CommandText = myCommand.CommandText
adapter.SelectCommand.Connection = myConnection
adapter.Fill(ds, "Result")
Try
myConnection.ConnectionString = "Integrated Security=etc etc;"
myConnection.Open()
If name.Checked = True Then 'see which checkbox is clicked
myCommand.CommandText = "SELECT artist,title,serial FROM database ORDER BY artist"
Else
If title.Checked = True Then
myCommand.CommandText = "SELECT artist,title,serialno FROM database ORDER BY title"
End If
myCommand.CommandText = "SELECT artist,title,serialno FROM database ORDER BY serialno"
End If
myCommand.Connection = myConnection
DataGrid.DataSource = ds
Catch
End Try
Displaying Math Results On Form
I have a form on which I want to display the results of some fairly simple mathmatical calculations. I would like the results to display as a percentage, but I'm not sure if VB can display a percentage. It would be acceptable for the result to display as 0.###. But it displays as 0.#######. I've tried formatting it using:
lblProc_r.Caption = CInt(CountSamp - i) / CountSamp
but this doesn't work.
Is there a way to format this?
Thanks, Lee
Displaying Results In Table (question)
Hello. I'm working on a program that basically converts fahrenheit to celsius and vice versa. I have it all complete but I am stuck on one thing. There are two text boxes and you enter a temperature range like 20 as the low temp. and 30 as the high temp. Say you are converting from fahrenheit to celsius When you click calculate it will calculate all of the INTEGERS between 20 and 30 and display them in a table like this
Fahrenheit ---------------------- Celsius
20 ------------------------- converted temp. whatever it may be.
21 ------------------------- converted temp. whatever it may be.
22 ------------------------- etc.
23
24
etc.
the results I want to be displayed in a text box or label, whichever one is better. I've tried both but can't figure how to display the results in a table like this. Any suggestions or tips? Thanks. =) Like I said I have everything else completed except displaying the results in a table like above.
Displaying Text/results To The Screen
Hi... My question is :What would be the best way to display results of my program as it is generating the results?
My app. finds errors in databases, and I want to display the results to the user as the program is going thru
and checking for the different errors.
I have tried using a picture box ..it worked ok until you moved another program in front of it.
I tried using a text box , but that gets messy for just displaying multi lines of text. alot of extra code.
I tried using a list box, but that does not display the results untill thel program has finished running.
Can any one give a suggestion on what I should use and how to set it up ?
Thanks in advance...
Trent
SSTab And Displaying Calculation Results
As part of a bigger project, I am using SSTab. I have three tabs. The first tab the user enters the data, The second tab will display the result of one calculation, the third tab displays another result. I understand how to move from one tab to the other using the tab key, but what I cannot seem to sort is the display of the results on the other tabs. I attach a short piece of coding and form which I have put together to help me understand how to get the program to work, but I cannot see why the results of the calcs will not display on the other tabs. Anyone tell me what I am doing wrong? Thanks
Displaying Results In Table(question)
Hello. I'm working on a program that basically converts fahrenheit to celsius and vice versa. I have it all complete but I am stuck on one thing. There are two text boxes and you enter a temperature range like 20 as the low temp. and 30 as the high temp. Say you are converting from fahrenheit to celsius When you click calculate it will calculate all of the INTEGERS between 20 and 30 and display them in a table like this
Fahrenheit ---------------------- Celsius
20 ------------------------- converted temp. whatever it may be.
21 ------------------------- converted temp. whatever it may be.
22 ------------------------- etc.
23
24
etc.
the results I want to be displayed in a text box or label, whichever one is better. I've tried both but can't figure how to display the results in a table like this. Any suggestions or tips? Thanks. =) Like I said I have everything else completed except displaying the results in a table like above.
Displaying Search Results In Access 2000
Hey yall. I have created a search form with another form to display the results. Long story short, I'm having problems with my code. So far, I have it working except that if there are more than one record, it only displays the last record found. What I did was on my search results form, I have added a combo box for the "Vendor's" Id. So when there are more than one record it will list the Id's in this box and I will be able to choose which one I want and have it display that information from that particular vendor. I'm thinking I am missing a list syntax somewhere to list the other records, however I'm not sure. Does anybody have any suggestions on why it would list the last record only, instead of all records found?
Thanks in advanced.
Datagrid Usage, Displaying Search Results.
Hi,
Im using a datagrid to display records from a access 97 database, i have 3 datacombo drop down boxes which are linked to specific fields in the database so when the user selects these they can select from whats in the database.
what i need it to do is for the user to select 1 or more of these datacombo boxes and then click a search button and for the results to be displayed in the datagrid that was originaly displaying the full list, this way they can see the full stock list at the start and also search for items in stock using this and then all i need to do is have a button to return to the full stock list once they have done with the searching.
For the life of me i just can't figure out how to get the search to display the results in the datagrid, the search works fine if i use a listbox for example so i know the search is ok, its just the displaying in the datagrid.
Comparing Results And Displaying Recordset In Textbox
Hey guys, I need some suggestion as to how about doing my project. Basically it's using ADO, VB6 and Access.
Things is that after scanning the bar code value into VB, I need to compare the results with the ones in the Access database and display them into text boxes. Below is the attached program I've written so far. The barcode will be scanned into the card_val and I was thinking that by comparing the value in card_val with the database, I can get the values of the other stuff and display them on those text boxes.
Or is it better to make a button whereby after scanning the bar code value into the card_val text box, a click on the button will make it search for result in the VB.
Thanks in advance.
Searching Database And Displaying Results In Listview...
hi yall, ive been trying to do this and i almost have it done but i cant get past this one bit. when my results display the display in a row(like the should) but then in the first column each row value repeates itsself, ive atached a printscreen so you can see and below is my code.. thnks in adnvacne for any help!!
Private Sub cmdSearch_Click()
Dim vList As ListItem
lstInfo.ListItems.Clear
Dim search As String
Dim Clientname As String
search = txtSearch.Text
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "SELECT * from tabCustomer WHERE [cusName] LIKE '%" & search & "%'"
Adodc1.Refresh
If Adodc1.Recordset.EOF Then
MsgBox "No record found matching " & search & "!!!"
Else
Adodc1.Recordset.MoveFirst
End If
lstInfo.ListItems.Clear
Do Until Adodc1.Recordset.EOF
On Error Resume Next
Set vList = Form5.lstInfo.ListItems.Add(, , Adodc1.Recordset.Fields(0))
vList.SubItems(1) = Form5.lstInfo.ListItems.Add(, , Adodc1.Recordset.Fields(1))
vList.SubItems(2) = Form5.lstInfo.ListItems.Add(, , Adodc1.Recordset.Fields(2))
Adodc1.Recordset.MoveNext
Loop
If Adodc1.Recordset.EOF And Adodc1.Recordset.RecordCount > 1 Then
MsgBox "Records Found"
End If
End Sub
Parsing A Text File Then Displaying Results In Program
Hello everyone,
I am trying to parse a 30k file that is located at C:FILE.txt
I would like to be able to enter a part of a server name into VB, have the program parse this file, then return all the server names that have strings similar to value I am searching for.
For example,
I would search for "cla". The program should display "clanonxp" and "clannings".
Does anyone know how to do this in vb6? I would appreciate any help. Thank you
Searching 3 Tables At A Time In Access And Displaying Results...
I wanna search for records in 3 access tables but using one query, if possible...and the search type is Date
so the query should be something like this but can't really construct it...please help
select * from [Tablenames] where date=smydate
and if nothing is found then an error should be displayed...
Displaying Search Results In MSHFlexGrid (Changing Bg-color In A Cell)
Hello
As you all probably remember by now, I'm working on a CD-Database. I'm using a MSHFlexGrid and an Access database with a Jet connection. The following is the code for my search function. The code that is bold is what I'm having problems with... It is supposed to:
1. Count number of records in database
2. Loop through the flexgrid
3. If a cell contains the same as what User is searching for, then
4. Make the cells background red (any color really).
What happens when I run the code is.. Nothing. I get no error message or anything, so I guess the error is logical. Anyone got any ideas? If not, got ideas for any other methods of solving my problem? I basically just want to highlight a row based on if the cell matches a search term entered by User.
Code:Private Sub cmdSearch_Click()
Dim strArtist As String, strTitle As String
Dim strArtistFound As String, strTitleFound As String
Dim intTotRecs As Integer
Dim i As Integer
Dim Con1 As ADODB.Connection
Dim Rec1 As ADODB.Recordset
strArtist = txtArtist.Text
strTitle = txtTitle.Text
Set Rec1 = New ADODB.Recordset
Set Con1 = New ADODB.Connection
Con1.Open ("Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=P:Cd-RegisterDatacd.mdb")
If optArtist.Value = True Then
'use sql to search for artist in database
Rec1.Open "SELECT fldArtist, fldTitle from tblCds WHERE fldArtist ='" & strArtist & "';", Con1, adOpenForwardOnly, adLockPessimistic
If Rec1.Fields("fldArtist") < 1 Then
i = MsgBox("No results found", vbOKOnly + vbInformation + vbApplicationModal, "CD Database Search - No Results")
Else
strArtistFound = Rec1.Fields("fldArtist") 'then the result assigned to var
strTitleFound = Rec1.Fields("fldTitle")
i = MsgBox("Results: " & strArtistFound & " - " & strTitleFound, vbOKOnly + vbInformation, "CD Database - Search Results") 'display results
'the following is supposed to highlight the row with the result
frmSearch.Hide
frmMain.Show
Rec1.Close
Rec1.Open ("SELECT * FROM tblCds ORDER BY fldArtist")
Do While Not Rec1.EOF
intTotRecs = intTotRecs + 1
Rec1.MoveNext
Loop
Rec1.Close
frmMain.dgdCd.Row = 1
For i = 1 To i = intTotRecs
If frmMain.dgdCd.Text = strArtistFound Then
frmMain.dgdCd.CellBackColor = vbRed
End If
frmMain.dgdCd.Row = frmMain.dgdCd.Row + 1
Next i
Exit Sub
End If
ElseIf optTitle.Value = True Then
Rec1.Open "SELECT fldTitle, fldArtist from tblCds WHERE fldTitle ='" & strTitle & "';", Con1, adOpenForwardOnly, adLockPessimistic
If Rec1.Fields("fldTitle") < 1 Then
i = MsgBox("No results found", vbOKOnly + vbInformation + vbApplicationModal, "CD Database - No Search Results")
Else
strTitleFound = Rec1.Fields("fldTitle")
strArtistFound = Rec1.Fields("fldArtist")
i = MsgBox("Results: " & strArtist & " - " & strTitle, vbOKOnly + vbInformation, "CD Database - Search Results")
Exit Sub
End If
End If
Set Rec1 = Nothing
Rec1.Close
Con1.Close
'after clicking ok in the msgbox displaying results, the search-dialog
'should be closed, and the artist selected in the flexgrid.
End Sub
Furthermore, I cannot figure out how to set the column header in a MSHFlexGrid. I've tried the following code;
Code:dgdCd.ColHeaderCaption(0, 0) = "HEJ"
but it doesn't seem to work at all. Nothing happens. I've tried to vary the numbers (0, 0) but no. Anyone know how to do it?
Thanks alot in advance for your help guys. I know that there's alot of knowledge out there on this forum
Edited by - pennywally on 3/19/2004 9:23:55 AM
Problems Displaying The Results Of A Parent/child/grandchild Data Shape
Can anyone help me?.
I have 3 tables Customers, Orders, Order Details. I have 1 form with 3 Datagrids. Datagrid1, Datagrid2, Datagrid3.
I am using the code with the Shape command below.
Private Sub Form_Load()
Dim db As Connection
Set db = New Connection
db.CursorLocation = adUseClient
db.Open "PROVIDER=MSDataShape;Data PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "DesignLog.mdb" & ";Persist Security Info=False;Jet OLEDB:"
Set adoPrimaryRS = New Recordset
adoPrimaryRS.Open "SHAPE {SELECT * from TblCustomers}APPEND ((SHAPE {select * from TblOrders} APPEND({select * from TblDetails} AS rsDetails RELATE OrderId TO OrderId)) AS rsOrders RELATE CustId TO CustId)", db, adOpenStatic, adLockOptimistic
Set DataGrid1.DataSource = adoPrimaryRS
Set DataGrid2.DataSource = adoPrimaryRS("rsOrders").UnderlyingValue
Set DataGrid3.Datasource = ????????' Not sure -????????????
What I want to show on the form is when I click a customer in Datagrid1 only Orders linked to that customer will show in DataGrid2 (This bit works ok).
When I click an order in DataGrid2 only order details linked to that order will appear in DataGrid3. SIMPLE!. How do I do It. I have been trying to get my head round this for days but would really appreciate someone to show me how to do it.
Thanks in advance.
Saltman
Help With Query Results
Hello all,
i'm trying to run a query:
SELECT table1.description, sum(table1.time_diff) AS footage, table1.machine, Sum(1) AS recordcount
FROM table1
GROUP BY table1.description, table1.machine;
and would like to add the query results into another database. could you all give some inputs?
thanks,
Sum Of SQL Query Results
Hi
i have a query with multiples tables, i have created the correct query to get values for a field named "cost". I don't want to display all the record i want to display the total of the cost of each record found.
Hope that makes sense
Thanks in advance
Not Getting Results From Query
Simple task...
Type in a number, find it, then show the owner.
Database goes to RS.EOF = True without finding the number and I know it's there.
Private Sub cmdEnter_Click()
Dim strPin As String
Dim conn As ADODB.Connection
Set conn = New ADODB.Connection
optFound.Value = False
optNFound.Value = False
strPin = txtInput
conn.ConnectionString = "DRIVER={MySQL ODBC 3.51 Driver};" _
& "SERVER=localhost;" _
& " DATABASE=ahmsys;" _
& "UID=root;PWD=abc; OPTION=3"
conn.Open
Set RS = New ADODB.Recordset
RS.Open "SELECT * FROM tenants WHERE ten_pin = " & strPin & " ", conn, adOpenDynamic, adLockOptimistic, adCmdText
If RS.EOF Then
optNFound.Value = True
Else
txtOut = RS("ten_name")
optFound.Value = True
End If
End Sub
This should be easy....... Thanks, Mikey
|