Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2014-12-22
4
85 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:
Simon 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 36

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

838 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