UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome to UtterAccess! Please ( Login   or   Register )

Custom Search
 
   Reply to this topicStart new topic
> Validate, Access 2016    
 
   
mike60smart
post Jun 27 2019, 02:37 PM
Post#1


UtterAccess VIP
Posts: 13,324
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

I am trying to use the following Code to Validate Controls on a Subform

CODE
Private Sub Form_BeforeUpdate(Cancel As Integer)

    On Error GoTo Form_BeforeUpdate_Error
Dim ctl As Control
Dim CName As String
For Each ctl In Me.Controls
  If ctl.Tag = "Reqd" Then
     If Nz(ctl, "") = "" Then
       CName = ctl.Controls(0).Caption
       MsgBox "Following field is required: " & vbCrLf & vbCrLf & CName
       Cancel = True
       ctl.SetFocus
       Exit Sub
     End If
   End If
Next ctl



    
    On Error GoTo 0
    Exit Sub

Form_BeforeUpdate_Error:

    MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_BeforeUpdate, line " & Erl & "."

End Sub


When I move off a record without filling in data for all required Controls I get the following error:-

Attached File  error.jpg ( 15.62K )Number of downloads: 0


Any Help appreciated


--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
Dan Dungan
post Jun 27 2019, 03:03 PM
Post#2



Posts: 319
Joined: 20-July 10
From: chatsworth, ca


What line does it error on?

--------------------
Dan
Go to the top of the page
 
pere_de_chipstic...
post Jun 27 2019, 03:09 PM
Post#3


UtterAccess Editor
Posts: 10,497
Joined: 8-November 07
From: South coast, England


Hi Mike

I've seen this error when the control doesn't have it's label 'attached'

Can you check which control it is failing on and check its label in the error message e.g.

MsgBox ctl.Name & CHR(13) & "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_BeforeUpdate, line " & Erl & "."

hth

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Jun 27 2019, 03:13 PM
Post#4


UtterAccess VIP
Posts: 13,324
Joined: 6-June 05
From: Dunbar,Scotland


Hi Dan & Bernie

I deleted the subform and recreated it.

All Labels are attached to Controls

Now when I try to add a New record in the Subform I get the following error.

Attached File  error.jpg ( 30K )Number of downloads: 6

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
pere_de_chipstic...
post Jun 27 2019, 03:23 PM
Post#5


UtterAccess Editor
Posts: 10,497
Joined: 8-November 07
From: South coast, England


Hi Mike

I think this is one of MS really useful error messages that don't help very much.

Can you check the Master/child relationship is intact on the subform control?

Else do a C&R

hth
This post has been edited by pere_de_chipstick: Jun 27 2019, 03:27 PM

--------------------
Warm regards
Bernie
Go to the top of the page
 
mike60smart
post Jun 27 2019, 03:52 PM
Post#6


UtterAccess VIP
Posts: 13,324
Joined: 6-June 05
From: Dunbar,Scotland


Hi Everyone

As Bernie said a standard error and the solution was to Import into a New Database

Thanks
cheers.gif

--------------------
Hope this helps?

Mike

Get happiness out of your work or you may never know what happiness is.

Go to the top of the page
 
pere_de_chipstic...
post Jun 27 2019, 03:55 PM
Post#7


UtterAccess Editor
Posts: 10,497
Joined: 8-November 07
From: South coast, England


Glad you got it sorted Mike thumbup.gif

--------------------
Warm regards
Bernie
Go to the top of the page
 


Custom Search


RSSSearch   Top   Lo-Fi    25th August 2019 - 10:31 AM