software:access:accessexamples
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| software:access:accessexamples [2023/10/15 23:06] – removed - external edit (Unknown date) 127.0.0.1 | software:access:accessexamples [2023/10/15 23:06] (current) – ↷ Page name changed from software:access:examples to software:access:accessexamples superwizard | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Examples ====== | ||
| + | [[http:// | ||
| + | ====== Execute SQL (ADO) ====== | ||
| + | http:// | ||
| + | |||
| + | Dim MySQL as String | ||
| + | MySQL = " | ||
| + | CurrentProject.Connection.Execute MySQL | ||
| + | |||
| + | ' Some examples of SQL statements (also see DAO above) | ||
| + | |||
| + | CurrentProject.Connection.Execute " | ||
| + | CurrentProject.Connection.Execute " | ||
| + | |||
| + | ' Alternative ADO syntax | ||
| + | |||
| + | Dim cd As New ADODB.Command | ||
| + | Dim cn As ADODB.Connection | ||
| + | Set cn = CurrentProject.Connection | ||
| + | cd.ActiveConnection = cn | ||
| + | cd.CommandText = MySQL | ||
| + | cd.Execute | ||
| + | |||
| + | ====== Internet Explorer Objects - msdn.microsoft.com ====== | ||
| + | |||
| + | * http:// | ||
| + | |||
| + | * http:// | ||
| + | |||
| + | * http:// | ||
| + | |||
| + | * http:// | ||
| + | |||
| + | * http:// | ||
| + | |||
| + | {{http:// | ||
| + | |||
| + | Once you have an instance of the Internet Explorer, you can manipulate it through properties and methods. For example, if you want the browser to appear and navigate to the New Technology Solutions, Inc., web site, you could use the following code: | ||
| + | |||
| + | MyBrowser.Visible = True | ||
| + | MyBrowser.Navigate " | ||
| + | |||
| + | You can use this type of coding to add browsing capabilities to Visual Basic projects or to create utilities for the browser. Listing 3-2 shows a complete project in Visual Basic that implements a Favorites list for the Internet Explorer browser. The project uses a small Microsoft Access database to keep track of your favorite URLs. These URLs are placed in a list box, from which users can pick a specified URL and cause the browser to navigate to it. Figure 3-6, on page 51, shows an example of the Favorites list box. | ||
| + | |||
| + | `This demo implements a Favorites list for the Internet | ||
| + | `Explorer 3.0. The list of favorite URLs is stored | ||
| + | `in a Microsoft Access database. | ||
| + | `This demo automatically launches the Internet Explorer. | ||
| + | `The user can jump to a favorite URL by selecting it from | ||
| + | `the list and clicking on the Navigate button or just | ||
| + | `double-clicking on the URL. | ||
| + | Option Explicit | ||
| + | Public MyBrowser As SHDocVw.InternetExplorer | ||
| + | |||
| + | Private Sub Form_Load() | ||
| + | `Get an instance of Internet Explorer 3.0 | ||
| + | Set MyBrowser = New SHDocVw.InternetExplorer | ||
| + | MyBrowser.Visible = True | ||
| + | `Fill list box with favorites | ||
| + | Call FillList | ||
| + | End Sub | ||
| + | |||
| + | Private Sub cmdNavigate_Click() | ||
| + | If lstFavorites.ListIndex = -1 Then Exit Sub | ||
| + | `Use the Navigate method to display the | ||
| + | `selected URL | ||
| + | MyBrowser.Navigate lstFavorites.List(lstFavorites.ListIndex) | ||
| + | End Sub | ||
| + | |||
| + | Private Sub lstFavorites_DblClick() | ||
| + | cmdNavigate.Value = True | ||
| + | End Sub | ||
| + | |||
| + | Private Sub FillList() | ||
| + | |||
| + | `Author: New Technology Solutions, Inc. | ||
| + | `Purpose: Fill list box from Favorites database | ||
| + | `6/2/96 Original | ||
| + | |||
| + | Dim dbFavorites As DAO.Database | ||
| + | Dim rsFavorites As DAO.Recordset | ||
| + | `Get favorites from database | ||
| + | Set dbFavorites = DBEngine.Workspaces(0) _ | ||
| + | |||
| + | .OpenDatabase(App.Path & " | ||
| + | Set rsFavorites = dbFavorites.OpenRecordset _ | ||
| + | (" | ||
| + | If rsFavorites.BOF And rsFavorites.EOF Then Exit Sub | ||
| + | lstFavorites.Clear | ||
| + | rsFavorites.MoveFirst | ||
| + | `Fill list box | ||
| + | Do While Not rsFavorites.EOF | ||
| + | lstFavorites.AddItem rsFavorites!URL | ||
| + | rsFavorites.MoveNext | ||
| + | Loop | ||
| + | rsFavorites.Close | ||
| + | dbFavorites.Close | ||
| + | Set rsFavorites = Nothing | ||
| + | Set dbFavorites = Nothing | ||
| + | End Sub | ||
| + | |||
| + | Private Sub cmdExit_Click() | ||
| + | Unload Me | ||
| + | End Sub | ||
