Toolbars

  • Thread starter Thread starter KA
  • Start date Start date
K

KA

How do you create a customized toolbar and remove the menu
bar in a query? In a report or form it is easy, but the
properties in a query do not let you remove the menu bar,
let alone create a cuatomized toolbar. Is there a way to
do this?
 
Remove the toolbar by unchecking:
Tools | Startup | Allow Built-in Toolbars

In any application where you want to control what the user can do, you do
not let them see the tables and queries directly. Use forms - Datasheet view
if you want it to look like a query.
 
-----Original Message-----
Remove the toolbar by unchecking:
Tools | Startup | Allow Built-in Toolbars

In any application where you want to control what the user can do, you do
not let them see the tables and queries directly. Use forms - Datasheet view
if you want it to look like a query.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.The reason I cannot use a form is because the query is
taking the place of a dynamic report, which access will
not create. Access will not create reports on the fly
where fields are inserted based on what you select in a
form. Therefore I am using a query in place of the report
because queries will insert and display only the fields
you want in them unlike reports, which forces you to
insert static fields into them. I turned off the allow
built-in toolbars and i still have a toolbar at the top of
my query. I also need to insert a customized toolbar in
the query.

Thank for any help in this matter.
 
Since you cannot assign a toolbar to a query, another option might be to
create the report with *unbound* text boxes - as many as the maximum number
the query could have.

Then in the Open event of the report, assign ControlSource of each of the
needed text boxes, the Visible property of the remainder, the Left and Width
of each text box (for desired spacing/layout), the Caption of each of the
labels, the ControlSource of your GroupLevels, etc.
 
-----Original Message-----
Since you cannot assign a toolbar to a query, another option might be to
create the report with *unbound* text boxes - as many as the maximum number
the query could have.

Then in the Open event of the report, assign ControlSource of each of the
needed text boxes, the Visible property of the remainder, the Left and Width
of each text box (for desired spacing/layout), the Caption of each of the
labels, the ControlSource of your GroupLevels, etc.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.




.You are right! I did do that but the problem arose when
the users wanted to not only see only the information that
they queried on. (that was easy), but they wanted the
fields that they queried to be the ONLY fields in the
report. In other words I had to tell the unbound fields
to have a width of 0.01 if they were null, and then tell
the populated fields to move over the null fields so that
the selected fields were next to each other in the
report. With 20 fields I can not even begin to think of
how many different combinations the users could select
when generating a report. Each selection forcing me to
script a layout for the fields. That is why I decided to
give them a query. The query will only display what they
select, and the fields will be next to one another. Can i
make a query look like a report?
 
No, you cannot control how the query looks.

Here is an example of dynamically assigning the control source and width of
controls on your report in its Open event. It assumes you have:
- the name of a query in the report's RecordSource.

- 20 unbound text boxes, side-by-side in the Detail section of the report,
with no labels attached, named txt00, txt01, txt02, ..., txt19.

- 20 labels, side-by-side in the Page Header section, named lbl00, lbl01,
...., lbl19.

Set the width of your report and the height of your sections as desired, but
the horizontal spacing and placement of the text boxes and labels does not
matter.

If you use fewer (or more) than 20 text boxes, set the value of
icMaxFieldsToHandle to the number you are providing.

Set the On Open property of the report to:
[Event Procedure]
Click the Build button (...) to open the code window.
Paste this in:

Private Sub Report_Open(Cancel As Integer)
'Purpose: Organize the text boxes on this report to match the fields
of the query.
'Assumes text boxes named txt00, txt01, ... and labels named lbl00,
lbl01, ...
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim iFieldCount As Integer
Dim iWidthEach As Integer
Dim i As Integer
Const icMaxFieldsToHandle = 5 'Max number of text boxes available.

'Get the querydef named in the report's RecordSource.
Set db = CurrentDb()
Set qdf = db.QueryDefs(Me.RecordSource)

'Get the number of fields in the source query.
iFieldCount = qdf.Fields.Count
If iFieldCount <= icMaxFieldsToHandle - 1 Then
'Hide boxes we do not need.
For i = iFieldCount To icMaxFieldsToHandle
Me.Controls("txt" & i).Visible = False
Me.Controls("lbl" & i).Visible = False
Next
ElseIf iFieldCount > icMaxFieldsToHandle Then
'Limit to available text boxes.
iFieldCount = icMaxFieldsToHandle
End If
'Calculate width for each text box.
iWidthEach = Int(Me.Width / iFieldCount)

'Assign the ControlSource and placement of each text box,
' and the Caption and placement of each label.
For i = 0 To iFieldCount - 1
With Me("txt" & i)
.ControlSource = qdf.Fields(i).Name
.Left = i * iWidthEach
.Width = iWidthEach
.Visible = True
End With
With Me("lbl" & i)
.Caption = qdf.Fields(i).Name
.Left = i * iWidthEach
.Width = iWidthEach
.Visible = True
End With
Next

'Clean up
Set qdf = Nothing
Set db = Nothing
End Sub
 
Back
Top