Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Field name and type
Message
From
02/11/2005 02:54:31
 
 
To
02/11/2005 01:46:39
General information
Forum:
Visual FoxPro
Category:
Other
Environment versions
Visual FoxPro:
VFP 6 SP3
OS:
Windows '98
Network:
Windows 98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01064365
Message ID:
01064376
Views:
24
>Dear Experts
>
>
>CLOSE ALL
>CLOSE DATABASES
>OPEN DATABASE D:\GIN2006\TABLES\ACCOUNT
>tbname=justfname(thisform.pageframe1.page2.list1.value)
>USE &tbname
>gnFieldcount = AFIELDS(gaMyArray)
>
>FOR nCount = 1 TO gnFieldcount
>   ? gaMyArray(nCount,1)
>ENDFOR
>
>The above codes work fine.
>But I want to add all field names and their type into list1 as
>
>debit n(8)
>credit n(8)
>detail c(20)
>
>List1 has two columns
>
>Please modify codes or suggest another
>Thanks in advance

Hey Tariq,

You might have to modify to fit your needs but this works with a standard form having a textbox to indicate the table named Text1 and a ListBox to display the fields named List1.
LOCAL lcFile as String, lcRowSource as String, lcAlias as String

STORE [] TO lcFile, lcRowSource, lcAlias

lcFile = ThisForm.Text1.Value

SELECT 0 
USE (lcFile) AGAIN 
lcAlias = ALIAS()

lnFieldCount = AFIELDS(laMyArray,lcAlias)
FOR nCount = 1 TO lnFieldCount
  lcFieldName = laMyArray[nCount,1]
  lcFieldType = laMyArray[nCount,2]
  lcFieldLength = TRANSFORM(laMyArray[nCount,3])
  lcFieldDecimal = TRANSFORM(laMyArray[nCount,4])

  lcColumn1 = lcFieldName
  lcColumn2 = lcFieldType + [(] + lcFieldLength + IIF(lcFieldDecimal#[0],lcFieldDecimal,[]) + [)]

  IF !EMPTY(lcRowSource)
  	lcRowSource = lcRowSource + [,]
  ENDIF 
  lcRowSource = lcRowSource + lcColumn1 + [,] + lcColumn2
ENDFOR

*!* Need to adjust to point to the correct object
ThisForm.List1.Width = 250
ThisForm.List1.ColumnCount = 2
ThisForm.List1.ColumnWidths = [125,125]
ThisForm.List1.RowSourceType = 1 && VALUE
ThisForm.List1.RowSource = lcRowSource

USE IN (lcAlias)
Previous
Reply
Map
View

Click here to load this message in the networking platform