Solved

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

Posted on 2014-12-22
4
87 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

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Familiarize people with the process of utilizing SQL Server views 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 Microsoft Access…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

685 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