Solved

How does this expression evaluate?

Posted on 1998-10-30
2
121 Views
Last Modified: 2010-04-30
Look at the following code please:

Form1.Data1.Recordset.FindFirst Form1.Text1.DataField & " = '" & "First Value" & "'"

The above statement works well, but I would prefer to use a variable for .Data1. and also .Text1.   but I don't know how   to get variables into that command string and have it evaluate without and error.

Thanks in advance.
0
Comment
Question by:tisd
2 Comments
 
LVL 3

Accepted Solution

by:
traygreen earned 200 total points
ID: 1442640
Pass the controls in to a proc and go from there.
You would determine which controls to send based on you or the user's selection.

Public Sub FindFirstInstance (pDataControl as control, pFindControl as control)

   If TypeOf pDataControl Is Data Then
      If TypeOf pFindControl Is TextBox Or _
         TypeOf pFindControl Is ComboBox Then
         
         pDataControl.RecordSet.FindFirst pFindControl.DataField & "='" & "First Value" & "'"
   
      End If
   End If
   
end sub
0
 

Author Comment

by:tisd
ID: 1442641
This technique worked well. Thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now