Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

view the contents of field of database

Posted on 1999-06-28
5
Medium Priority
?
146 Views
Last Modified: 2011-08-18
for having a database(written in access) that have 2 fields one is an id field(number)and other is path field (string) .
i need a function that accept from me number (as id )then returns to me the contents of the corresponding field(string)and print it to me in var or in message box



0
Comment
Question by:twity
[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
  • 2
5 Comments
 
LVL 1

Expert Comment

by:Dreamn3d
ID: 1520360
what are you using for your connection object?  ADO, RDO, or DAO?
0
 
LVL 1

Accepted Solution

by:
SergioL earned 120 total points
ID: 1520361
In DAO 3.51:
Public wks As Workspace
Public dbs As Database
Public rstProductos As Recordset
Set wks = CreateWorkspace("", "admin", "")
Set dbsNJ2000 = wks.OpenDatabase("C:\db.MDB", , False)
Set rstProductos = dbs.OpenRecordset("Productos", dbOpenDynaset)

Do While not rstProductos.Eof()
  Debug.Print rstProductos.Fields(0).Value  '<-- This is
  Debug.Print rstProductos.Fields(1).Value  '    for you.
ENDDO

0
 
LVL 1

Expert Comment

by:Dreamn3d
ID: 1520362
In ADO:

dim cn as adodb.connection
dim rs as adodb.recordset
dim rsQuery as adodb.recordset

set cn = new connection
    with cn
       .provider "microsoft.jet.oledb.3.51"
       .connectionstring = _
'connection path
"c:\program files\microsoft\office\office\samples\northwind.mdb"
       .open
    end with

set rs = new adodb.recordset
     with rs
       .cursorlocation = aduseclient
       .open "select * from table_name", cn, adOpenStatic, adLockBatchOptimistic
       .sort = "idfield ASC"
     end with

public sub command1_click()
     strQueryText = (inputbox(What ID would you like to search by?))
     strQueryPass = Trim(strQueryText)
            If strQueryPass <> "" Then
                  ' Open a filtered Recordset object.
 Set rsQuery = FilterField(rs, "idfield", strQueryPass)
                If rsQuery.RecordCount = 0 Then
               MsgBox "No Members with specified last name."
                Else
            'Give user feedback via msgbox
  strMessage = "Number of records where idfield = '" & _
              strQueryPass & "': " & rs.recordcount
              msgbox strquerypass        
  End If
            End If

end sub

Note:

Most of this came straight from MSDN library, perform a search on ado AND requery and modify to your hearts content.
Jesse
0
 
LVL 1

Expert Comment

by:Dreamn3d
ID: 1520363
this ones for sergiol, I felt that since you were trying to gank a question I had started to answer I'd return the favor,


0
 
LVL 1

Expert Comment

by:SergioL
ID: 1520364
for Dreamn3d:
I show a way to do that, I DON'T TRY "TO GANK" ANY QUESTION.
OK!?
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
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…
Suggested Courses

705 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