Solved

How to bring up a table in code and pause for edit

Posted on 2014-12-22
4
81 Views
Last Modified: 2015-02-27
I'm running code thru a button and I need to inspect data in a table before final processing and sending out. Right now it does the opentable cmd and right after I put out a msgbox is it good ? (yes no) But I don't have the capability to edit it right then and there. Is there a way that I'm not thinking of that can pause the opentable and allow editing with the msgbox there or another way of doing it?
0
Comment
Question by:Grizbear51
4 Comments
 
LVL 18

Accepted Solution

by:
SimonAdept earned 500 total points
ID: 40513934
I think the 'normal' way to do this would be to open a form containing a subform based on the table in datasheet view, and the button to proceed with final processing on the main form. This would mean attaching the 2nd part of your code to this button.

If that doesn't work for your process design, you could display the editing form (with subform) as pop-up modal dialog, with cancel and proceed buttons and read the return value in your original code, either by setting a global variable from the proceed button, or by making the proceed button just set the form visible=false and then checking and then closing the form from the code that called it.
0
 
LVL 34

Expert Comment

by:PatHartman
ID: 40514074
It is poor practice to pop open tables or queries for user editing.  Always use a form so you can apply validation logic to ensure only good data is saved.  Using that concept, to make the form available for editing while the code is running, open the edit form as a dialog.  That will stop the code in the main form from running until the model form is closed.  Then the code in the main form will continue where it left off.

docmd.OpenForm "formname",acNormal,,"where condition if necessary",acFormEdit,acDialog

So immediately following the OpenForm method, you can have a message box that asks whether or not to export and proceed from there.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40518784
I too am a bit confused by your interface.
Are you simply displaying "Yes" or "No" in the message box text, ...or are you actually using the arguments of the message box to actually display Yes or No "buttons"

In any event, ...a message box will always halt your application until you close it.
In other words, ...it can't really "float" above your app, and still let you make edits while it is still displayed.

Read through the other experts posts first, ..

But also consider doing his another way...
For example, suppose the user looks at the data and thinks: "Yeah that looks OK to me."... and clicks YES, (to process the data)
...But the data was actually incorrect or invalid (...and the bad data gets "processed" anyway)
...then what?

In other words, why would a user need to inspect data that already exists in a table?
Why not validate the data with automation beforehand (when the data is first being entered) and eliminate the need for manual/human inspection (that may, or may not catch errors)

There are many techniques for validating data
You did not state what your users will be checking for, ...but some very rough examples are:

Missing data:
If me.YourControl="" or isnull(me.yourcontrol) Then
    Msgbox "You must enter a value"
    'Do something else
End If

Invalid Data:
If Len(Me.txtOrderID)<>7 Then
    msgbox "Order ID must be 7 characters"
    'Do something else
end if

Data already exists:
If DCount("locName", "tblLocations", "locName=" & "'" & Me.locName & "'") > 1 Then
    MsgBox "Name already exists"
    'Do something else
End If

Date Data:
If ShipDate<OrderDate Then
    Msgbox "Ship Date cannot be before the Order Date"
    'Do something else
End If

The benefit here is that complex things can be done that humans may have trouble with, like multile criteria (is over 27 year old and has less than 9 outstanding orders)
...or have values that are difficult to read (which is greater 1010010110101010 or 10100101101010)
   

Most of these techniques can be used on the Before Update event of a form
The actual code may need a "Cancel" and/or a "Me.Undo" command.
You can research many of these techniques here, or by doing a Web search

;-)

JeffCoachman
0
 

Author Closing Comment

by:Grizbear51
ID: 40635629
I agree  I was looking for a simpler way to edit data before sending it out but I guess it has to be this way
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article is a continuation or rather an extension from Cascading Combos (http://www.experts-exchange.com/A_5949.html) and builds on examples developed in detail there. It should be understandable alone, but I recommend reading the previous artic…
Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

759 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

19 Experts available now in Live!

Get 1:1 Help Now