Solved

Macro in Visual Basic

Posted on 1999-01-27
2
166 Views
Last Modified: 2013-11-25
To_Experts

I have a problem regarding macro which i described
below.Here i retrieve fieldname from array.
e.g.-> "SR_NO" is fieldname

coding:

Dim TempStoreNumber As Integer
Dim NumberOfArray As Integer
dim rsiled as recordset

For TempStoreNumber = 0 To NumberOfArray
 With rsiled
  X1 = "!" + TempArrayfieldname(TempStoreNumber)
  MSFlexGrid1.TextMatrix(1,TempStoreNumber) = " " & X1 & " "
 End With
Next
      
Points:

 1) I got x1 = "!SR_NO"  
 2) I got msflexgrid1.textmatrix(1,TempStoreNumber)="!SR_NO"            

Both are same.Actually in first point i got correct value(field name).
But in second point i want value of that value(means fieldname's value).

I want the value of "SR_NO" (Fieldname of a table) from table.
which i want to pass in msflexgrid which i mentioned below.

   msflexgrid1.textmatrix(1, TempStoreNumber) =


Please reply us with full coding.

with warm regards,
Bhavesh Patel
0
Comment
Question by:Aurokripa
2 Comments
 
LVL 1

Expert Comment

by:batdan
ID: 1470908
You may want to delete this question.  It has been posted twice!
0
 
LVL 12

Accepted Solution

by:
mark2150 earned 20 total points
ID: 1470909
It's not going to work. The field name is being interpritted as a string and *NOT* as a field reference.

Set db = Workspaces(0).OpenDatabase(datadir)
For Each Table In db.TableDefs
    work = Table.Name
    If UCase(Left(work, 4)) <> "MSYS" Then Combo1.AddItem Table.Name
Next Table
'
Data1.Caption = datadir
Data1.DatabaseName = datadir           'set link to database
Combo1.ListIndex = 0
Set Data1.Recordset = db.OpenRecordset(Combo1.Text) ' Defaults to Table object.

For Each td In db.TableDefs
For Each fd In td.Fields
        Printer.Print fd.Name
Next fd
next td

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…

747 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