Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2014-12-22
4
Medium Priority
?
95 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:Stephen Roesner
[X]
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
4 Comments
 
LVL 18

Accepted Solution

by:
Simon earned 1500 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 39

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:Stephen Roesner
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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

721 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