Cancel save after BeforeUpdate code runs

This code opens the form in the state I want to see it. I am wondering if there is a more succinct way to code it.......can the Loops be combined somehow?

Code:
Private Sub Form_Load()
    

    
  Dim rs As DAO.Recordset
    If Not Trim(Me.OpenArgs & " ") = "" Then
        'See if record exists
        Set rs = Me.Recordset
        'MsgBox Me.OpenArgs
        rs.FindFirst "InspectionEvent_FK = " & CLng(Me.OpenArgs)
            If rs.NoMatch Then  'it does not exist so you need to create it
                DoCmd.GoToRecord acDataForm, Me.Name, acNewRec
                Me.InspectionEvent_FK = Me.OpenArgs
                Me.txtFinalProd_FK = intFinalProdID
                Me.NavigationButtons = False
                Me.cmdSaveLineStop.Enabled = False
                For Each ctl In Me.Controls
                    If ctl.Tag = "required" Then
                    ctl.Enabled = False
                    End If
                Next
                For Each ctl In Me.Controls
                    If ctl.Tag = "secondary" Then
                    ctl.Enabled = False
                    End If
                Next
                Me.cboLine1Workstation.Enabled = True
            End If
    Else
        If IsNull(Me.OpenArgs) Then
            Me.Filter = "LineStopBegin Is Not Null AND LineStopEnd Is Null"
            Me.FilterOn = True
            Me.NavigationButtons = True
        End If
    End If
 End Sub
Yes, you can combine the loops by using either an Else or ElseIf branch, or my favorite, Select Case statement.


Edit: Wait a minute... You're disabling all the controls in your code! If so, you should be able to do something like:
Code:
If ctl.Tag = "required" OR ctl.Tag = "secondary" Then
 
Yes, you can combine the loops by using either an Else or ElseIf branch, or my favorite, Select Case statement.

I am actually starting to have less headaches and more fun with this. :-) lol
 
I am actually starting to have less headaches and more fun with this. :-) lol
Hi. Please check out the edit to my last post. Thanks.
 
Yes, you can combine the loops by using either an Else or ElseIf branch, or my favorite, Select Case statement.


Edit: Wait a minute... You're disabling all the controls in your code! If so, you should be able to do something like:
Code:
If ctl.Tag = "required" OR ctl.Tag = "secondary" Then

Yep - that's the idea. Turn them ALL off and then turn the one I want the user to focus on back on. :-)

Then I'm going to use the On Dirty event of each control in succession to guide the user until I get to the 3rd control. It's On Dirty will include your loop and turn the remainder of the tags all back on via that tag - - which I currently have a big crush on. :-)
 
Yep - that's the idea. Turn them ALL off and then turn the one I want the user to focus on back on. :-)

Then I'm going to use the On Dirty event of each control in succession to guide the user until I get to the 3rd control. It's On Dirty will include your loop and turn the remainder of the tags all back on via that tag - - which I currently have a big crush on. :-)
Give it a shot and let us know how it goes...
 
The real proof will be when my protege at work figured out how to break it :-)
 
You don’t sound to hopeful - lol
I just have a feeling we're not done yet... After all, we don't have any idea about what you're actually trying to do (I think).
 
I just have a feeling we're not done yet... After all, we don't have any idea about what you're actually trying to do (I think).

I guffawed - fwiw. I suppose not.

I am working on a form called Line Stop that HAS TO HAVE data entered in 3 fields or it is a waste of time.

I am making it so that the user (me and 2 others who care far less than I do) have zero recourse but to enter data in to those 3fields before they are able to move on.

Once those 3 fields have data, it all becomes subjective and they can enter data into the rest of the controls with little compromise.
 
………and I don’t know if I have ever mentioned this but the whole front end of this is going on a tablet.
 
Using Access or something else?

Using Access. Shopping for the right rugged tablet was an………………adventure. It’s also why I am designing the forms the way I am. Very little desktop.
 
We have very good Wifi and cellular in the plant- also investing in all peripherals docking stations etc
 
Our ERP is SQL Server based but there is very little required interface between the two. We can all get what we need/want via delimited files easily.
 
We have very good Wifi and cellular in the plant- also investing in all peripherals docking stations etc
Again, this is one of those, give it a try and let us know how it goes because Access and Wifi were never meant to be used together.
 
Again, this is one of those, give it a try and let us know how it goes because Access and Wifi were never meant to be used together.

……yeah……………it COULD mean a daily Append query process from multiple tablets…………we’ll see. In any regard - when I started here two years ago - everything was still on paper - in piles - collecting dust - w/out value…so…


That said…

I know you’re not saying something :-)

Is SQL Server able to WiFi or cellular?

And if so … can my current work be converted to some extent?
 
I should mention that I have worked extensively via VPN with a remote front end and remote on the network back end without issue.
 
I googled.

Really only found one article BUT it speaks very clearly to what you suggest so....

Since we already utilize VPN we will likely make it requisite that the tablets are connected via VPN remote desktop rather than trying to do the work over wifi.

As always - - - I will report back :-)
 
BTW - & FWIW - and returning to the main gist of this post - I finally coded everything I laid out earlier and it works great!

Thank You!

That simple loop utilizing the control tags as a marker makes the entire thing really simple.
 

Users who are viewing this thread

Back
Top Bottom