if statement vba in access (1 Viewer)

mana

Registered User.
Local time
Today, 05:17
Joined
Nov 4, 2014
Messages
265
hello
i wrote the following button in a form
but it doesn't go to the if statement at all
can you help me please?
where is my fault?




If Me.Fehlteil.Value = "" Then
DoCmd.OpenForm "frm_logistik_zeitfehlerein_detail_emptyfields", , , acFormDS
Else

On Error GoTo Err_Befehl14_Click
Dim stDocName As String
Dim stLinkCriteria As String




stDocName = "frm_logistik_zeitfehlerein_detail"

stLinkCriteria = "[Fehlteil]=" & "'" & Me![Fehlteil] & "'"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Exit_Befehl14_Click:
Exit Sub
Err_Befehl14_Click:
MsgBox Err.Description
Resume Exit_Befehl14_Click
End If
 

mana

Registered User.
Local time
Today, 05:17
Joined
Nov 4, 2014
Messages
265
hello
the following is the code



Code:
Private Sub Text52_Click()
  If Me.Fehlteil.Value = "" Then
    DoCmd.OpenForm "frm_logistik_zeitfehlerein_detail_emptyfields", , , acFormDS
    
   Else
On Error GoTo Err_Befehl14_Click
    
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frm_logistik_zeitfehlerein_detail"
    stLinkCriteria = "[Fehlteil]=" & "'" & Me![Fehlteil] & "'"
    DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Exit_Befehl14_Click:
    Exit Sub
Err_Befehl14_Click:
    MsgBox Err.Description
    Resume Exit_Befehl14_Click
 End If
End Sub
 

mana

Registered User.
Local time
Today, 05:17
Joined
Nov 4, 2014
Messages
265
hello

did you see the code?
can you say what my problem is please?
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:17
Joined
Sep 21, 2011
Messages
14,288
Your code should be along the lines of below. I always put DIM statements at the top but that is a matter of preference I suppose.

You say it is not going to the If statement?. Have you tried setting a breakpoint on that line and F8 in Debug to see where the code goes.?

Code:
Private Sub Text52_Click()
On Error GoTo Err_Befehl14_Click

  If Me.Fehlteil.Value = "" Then
    DoCmd.OpenForm "frm_logistik_zeitfehlerein_detail_emptyfields", , , acFormDS
    
   Else

    
    Dim stDocName As String
    Dim stLinkCriteria As String
    stDocName = "frm_logistik_zeitfehlerein_detail"
    stLinkCriteria = "[Fehlteil]=" & "'" & Me![Fehlteil] & "'"
    DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
 End If
Exit_Befehl14_Click:
    Exit Sub
Err_Befehl14_Click:
    MsgBox Err.Description
    Resume Exit_Befehl14_Click

End Sub
 

BigHappyDaddy

Coding Monkey Wanna-Be
Local time
Today, 05:17
Joined
Aug 22, 2012
Messages
205
Just throwing this out there:

If the value of Me.Fehlteil.Value is null, then the true portion of the if statement will not execute.

Is this what you are seeing? If so, change the if statement to
Code:
If Nz(Me.Fehlteil.Value,"") = "" Then
 

CJ_London

Super Moderator
Staff member
Local time
Today, 13:17
Joined
Feb 19, 2013
Messages
16,610
i wrote the following button in a form

and is your button really called text52?

text52 looks like the default name for a textbox, buttons default to command52
 

Gasman

Enthusiastic Amateur
Local time
Today, 13:17
Joined
Sep 21, 2011
Messages
14,288
I think CJ has just spotted your problem. :D
 

Users who are viewing this thread

Top Bottom