Need Readonly query output (1 Viewer)

ashishprem

Registered User.
Local time
Today, 00:48
Joined
Mar 18, 2008
Messages
35
Hi,

I have a made a query named "Alert_data" in query option which selects the data from a table. When i click a button in a form this query output should be displayed.I am using the code in the button click event as

DoCmd.OpenQuery "Alert_data"

Its working fine. But the problem is if i edit any cell in the output it gets reflected in the table. Anyway to display the data as readonly. I tried to display the data in GRID but I am unable to bind the query output to the GRID.

Any help.

Ashish
 

boblarson

Smeghead
Local time
Today, 00:48
Joined
Jan 12, 2001
Messages
32,059
Use a form and set it to display as Datasheet. You can then set the AllowEdits property to NO so edits can't be made.
 

ashishprem

Registered User.
Local time
Today, 00:48
Joined
Mar 18, 2008
Messages
35
Hi Bob,
I can see from the form property window the place where to make the allow property to NO. But struggling to find the display as Datasheet. and how can i link the query output to form datasheet.

Ashish
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 08:48
Joined
Sep 12, 2006
Messages
15,653
make a form based on your query, "alert data".

on this form set "allow edits", "allow additons", "allow deletes" all to false

now instead of

DoCmd.OpenQuery "Alert_data"

its just

DoCmd.OpenForm "frm_Alert_data"

[edit - mote that one of the form properties (i forget which - near the top) - allows you to select view type as single form, continuous form, or datasheet]
NOTE: Instead of needing to pop this up in realtion to a button click, or maybe field dble-click, you can put a filter on this open statement to only show selected rows (eg those for a given status etc), even if the filter is not present in the query.

you could even embed this second form as a subform in the main form, and again it would only show items related to the selected mainform row (if you have a suitable relationship), and it would refresh this link automatically

It all comes down to the presentation you want to have, and how much space you have on your screen available - form design is important, and sometimes too much info on the screen can look awkward
 
Last edited:

GuruBrent

New member
Local time
Today, 08:48
Joined
Mar 22, 2008
Messages
1
Hi,

I have a made a query named "Alert_data" in query option which selects the data from a table. When i click a button in a form this query output should be displayed.I am using the code in the button click event as

DoCmd.OpenQuery "Alert_data"

Its working fine. But the problem is if i edit any cell in the output it gets reflected in the table. Anyway to display the data as readonly. I tried to display the data in GRID but I am unable to bind the query output to the GRID.

Any help.

Ashish
You have choices:
1. You can export the whole query result into Excel and then play with it to your hearts content without affecting the database.
2. Follow Bob Larson's advice.
3. Follow gemma-the-husky's advice
 

ashishprem

Registered User.
Local time
Today, 00:48
Joined
Mar 18, 2008
Messages
35
This seems to work but dont know why its not working for me.
I tried something like this:

Created a new form. In design view of the form I went to record source and selected the query "Alert_data". and changed the form default view property to datasheet. When i open the form though it opens in datasheet but it doesn't return any records. But when i open the query alone it gives a record as output. Dont know where I am missing any property or something else.

Ashish
 

Users who are viewing this thread

Top Bottom