473,405 Members | 2,445 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,405 software developers and data experts.

how to show the results of MS Access database query in Visual basic

24
Hello I want to show the results of MS Access database query in Visual basic. Do you know how to do this? I want to show the results in objects such as label or text box. Please help me. My code is:

Dim db As Database
Dim rec As Recordset

Private Sub Command1_Click()
Set db = OpenDatabase("the patht of database")
MsgBox "database is open"
Set rec = db.OpenRecordset("SELECT DISTINCT asmenu_info.Vardas FROM asmenu_info;")
While Not rec.EOF
Label1.Print rec!vardas
rec.MoveNext
Wend
rec.Close
db.Close
End Sub

If i do this with second form everythig is ok, but I want to do this with label or text box
Apr 26 '07 #1
1 1836
bhar
37
Hi,

Private Sub Form_Load()
Set rsgroup = New ADODB.Recordset
Set rsaccount = New ADODB.Recordset
rsgroup.CursorLocation = adUseClient
rsaccount.CursorLocation = adUseClient
rsgroup.Open “SELECT * FROM NGROUP WHERE GHIDDEN <> -1”, CN, adOpenDynamic, adLockOptimistic, adCmdText
rsaccount.Open “SELECT * from PARTY”, CN, adOpenDynamic, adLockOptimistic
If rsaccount.RecordCount > 0 Then
Do While rsaccount.EOF = False
List1.AddItem rsaccount(“pname”)
rsaccount.MoveNext
Loop
rsaccount.MoveFirst
End If
If rsaccount.RecordCount > 0 Then
mname = rsaccount!PName
mdes = rsaccount!pdes
madd1 = rsaccount!address1
madd2 = rsaccount!address2
mphone = rsaccount!phone
mfax = rsaccount!fax
mcity = rsaccount!city
mamount = rsaccount!opamt
End If
mname.Enabled = False
mdes.Enabled = False
madd1.Enabled = False
madd2.Enabled = False
mcity.Enabled = False
mphone.Enabled = False
mfax.Enabled = False
mamount.Enabled = False
savebutton.Enabled = False
cancelbutton.Enabled = False
Newbutton.Enabled = True
Editbutton.Enabled = True
deletebutton.Enabled = True
End Sub

Database programming in Visual basic
Apr 27 '07 #2

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

Similar topics

9
by: Rich May | last post by:
Afternoon all, Apologies for cross-posting but as my query covers both Access and SQL Server I thought I'd send it both! I have inherited a project to migrate a fairly complex series of...
1
by: marina madeleine | last post by:
Could some clarify for me - I thought the scripting language for Access was SQL and that to script in Access one would need to learn SQL. Why then is the Access database under visual basic? What...
52
by: Neil | last post by:
We are running an Access 2000 MDB with a SQL 7 back end. Our network guy is upgrading to Windows Server 2003 and wants to upgrade Office and SQL Server at the same time. We're moving to SQL Server...
7
by: fcolon75 | last post by:
I'm an experienced Access user, but very new to coding VBA in Access. I'd like to do the following: 1) Develop a basic query in the query designer. 2) Call that query from a VBA script 3)...
6
by: amir | last post by:
hello again, i was wandering if there is an easy way to export text from my database to an html report... amir.
11
by: RivaCom | last post by:
I am using a Access Database to search/add a bunch of information in MS VB.net 2005 express. In the query (querybuilder) everything seems right, but in the WHERE statement I use = me.textbox.text...
5
by: Eglute | last post by:
Hello I want to show the results of database query in Visual basic. Do you know how to do this? I want to show the results in objects such as label or text box. Please help me. My code is: Dim db...
3
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window...
2
by: swb76 | last post by:
I have a query in MSAccess and it is a select query. As i understand, any query run from Visual Basic would be returned in a recordset. Can i display the results to the user in a datasheet view?...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
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...
0
agi2029
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,...
0
isladogs
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...

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.