Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Report Form with Variable Input 1

Status
Not open for further replies.

moepower

Programmer
Oct 5, 2000
93
US
I want to create a command button in the Form window so that when clicked, it brings up a list of fields. Depending on which fields were selected, I want to print a pre-designed report with the selected fields as the sort criteria. Is this doable in MS Access?

Thanks
 
Yep
VBA is very powerful

Look at "QueryDef" and "Field Properties Reference"
in Help

you could create an empty Tablecalled "TableFields"
then open a recordset that has the fields from the Table whose fields you want in it
then write those fields to that table
finally base a report on the table "TableFields"

here is something from Help in A2K
------------------------ this is a basis of what you need to do --------------------
Attributes and Name Properties Example (VB)


This example displays the value of the Attributes property for Connection, Field, and Property objects. It uses the Name property to display the name of each Field and Property object.

Public Sub AttributesX

Dim cnn1 As ADODB.Connection
Dim rstEmployees As ADODB.Recordset
Dim fldLoop As ADODB.Field
Dim proLoop As ADODB.Property
Dim strCnn As String

' Open connection and recordset.
strCnn = "Provider=sqloledb;" & _
"Data Source=srv;Initial Catalog=Pubs;User Id=sa;Password=; "
Set cnn1 = New ADODB.Connection
cnn1.Open strCnn
Set rstEmployees = New ADODB.Recordset
rstEmployees.Open "employee", cnn1, , , adCmdTable

' Display the attributes of the connection.
Debug.Print "Connection attributes = " & _
cnn1.Attributes

' Display the attributes of the Employee table's
' fields.
Debug.Print "Field attributes:"
For Each fldLoop In rstEmployees.Fields
Debug.Print " " & fldLoop.Name & " = " & _
fldLoop.Attributes
Next fldLoop

' Display Fields of the Employee table which are NULLABLE.
Debug.Print "NULLABLE Fields:"
For Each fldLoop In rstEmployees.Fields
If CBool(fldLoop.Attributes And adFldIsNullable) Then
Debug.Print " " & fldLoop.Name
End If
Next fldLoop

' Display the attributes of the Employee table's
' properties.
Debug.Print "Property attributes:"
For Each proLoop In rstEmployees.Properties
Debug.Print " " & proLoop.Name & " = " & _
proLoop.Attributes
Next proLoop

rstEmployees.Close
cnn1.Close

End Sub

------------------------------



DougP, MCP
dposton@universal1.com

Ask me how Bar-codes can help you be more productive.
Or visit my WEB site
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top