Page 2 of 3 FirstFirst 123 LastLast
Results 16 to 30 of 35
  1. #16
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Can you show the entire code you have for the form (CO_pakiranje_SD14)? You should have all the building pieces now, you have to decide how you want to control the flow. If you want to disable the two controls after a valid Pin is entered you do it in the AfterUpdate event of the PIN textbox.
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  2. #17
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Can you show the entire code you have for the form (CO_pakiranje_SD14)? You should have all the building pieces now, you have to decide how you want to control the flow. If you want to disable the two controls after a valid Pin is entered you do it in the AfterUpdate event of the PIN textbox.
    Code:
    Private Sub potpis_operater_AfterUpdate()
    Dim Username As String
        Dim strSQL As String
        Dim strMsg As String
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim password_check As Integer
        
        Username = Form_CO_pakiranje_SD14.operater_p
        Set dbs = CurrentDb()
        strSQL = "SELECT password FROM Evidencija_radnika WHERE ime_prezime = '" & Username & "';"
        Set rst = dbs.OpenRecordset(strSQL)
        password_check = rst![Password]
        rst.Close
        
        If CInt(Form_CO_pakiranje_SD14!potpis_operater) <> password_check Then
        strMsg = Username & ", niste unijeli tocan PIN!"
            MsgBox strMsg
            Form_CO_pakiranje_SD14!potpis_operater = Null 'Vlad you want to make the control Null not empty string ""
             Me.operater_p.Enabled =True
           Me.potpis_operater.Enabled=True
    
        Else
            'Form_CO_pakiranje_SD14!potpis_operater = password_check 'Vlad don't need this as they are already equal otherwise you won't get here
            strMsg = Username & ", uspjesno potvrden PIN!"
            MsgBox strMsg
            Me.operater_p.Enabled =False
            Me.potpis_operater.Enabled=False
    
        End If
        
        Set rst = Nothing
        Set dbs = Nothing
        
    End Sub
    Did you put the previous code in the Current event of the form?

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #18
    santon's Avatar
    santon is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    44
    Quote Originally Posted by accesstos View Post
    Hi all!

    Please try this version of your potvrda_pin_Click procedure and check if it works properly (I didn’t):
    I have tried it, it gives no errors but it doesn't work correctly, when I click on the button to confirm PIN nothing happens.






    Vlad, here is the code in have in that form, which is here in after update for "potpis_operater" text box
    Code:
    Private Sub potpis_operater_AfterUpdate()
    
    Dim Username As String
        Dim strSQL As String
        Dim strMsg As String
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim password_check As Integer
        
        Username = Form_CO_pakiranje_SD14.operater_p
        Set dbs = CurrentDb()
        strSQL = "SELECT password FROM Evidencija_radnika WHERE ime_prezime = '" & Username & "';"
        Set rst = dbs.OpenRecordset(strSQL)
        password_check = rst![Password]
        rst.Close
        
        If CInt(Form_CO_pakiranje_SD14!potpis_operater) <> password_check Then
        strMsg = Username & ", niste unijeli tocan PIN!"
            MsgBox strMsg
            Form_CO_pakiranje_SD14!potpis_operater = Null 'Vlad you want to make the control Null not empty string ""
             Me.operater_p.Enabled = True
           Me.potpis_operater.Enabled = True
    
    
        Else
            'Form_CO_pakiranje_SD14!potpis_operater = password_check 'Vlad don't need this as they are already equal otherwise you won't get here
            strMsg = Username & ", uspjesno potvrden PIN!"
            MsgBox strMsg
            Me.operater_p.Enabled = False
            Me.potpis_operater.Enabled = False
    
    
        End If
        
        Set rst = Nothing
        Set dbs = Nothing
        
    End Sub
    Click image for larger version. 

Name:	operater.JPG 
Views:	22 
Size:	18.5 KB 
ID:	43643
    Click image for larger version. 

Name:	operater2.JPG 
Views:	22 
Size:	21.0 KB 
ID:	43644



    And this is the error it shows:

    Click image for larger version. 

Name:	error.JPG 
Views:	22 
Size:	39.2 KB 
ID:	43645

  4. #19
    accesstos's Avatar
    accesstos is offline Expert
    Windows XP Access 2007
    Join Date
    Dec 2018
    Location
    Greece
    Posts
    551
    If the operater_p is actually a combobox, this is a fake compile error. Probably, your code has syntax errors somewhere else in your project. Comment the line(s) that compiler highlights and keep compile your code until find the actual error.

    In general, try to read our messages and, especially, try to read between the lines.

    Good luck!

  5. #20
    santon's Avatar
    santon is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    44
    Quote Originally Posted by accesstos View Post
    If the operater_p is actually a combobox, this is a fake compile error. Probably, your code has syntax errors somewhere else in your project. Comment the line(s) that compiler highlights and keep compile your code until find the actual error.

    In general, try to read our messages and, especially, try to read between the lines.

    Good luck!

    Thank you, I fixed it, combobox had different name.
    But again when it disables the fields, it also disables them for new records as I said before

  6. #21
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    5,030
    Quote Originally Posted by santon View Post
    Thank you, I fixed it, combobox had different name.
    But again when it disables the fields, it also disables them for new records as I said before
    So check for Me.NewRecord ?

    You were given this option in this thread of yours?

    https://www.accessforums.net/showthread.php?t=82425&highlight=me.newrecord


    You have to start applying techniques that you have been given in other tasks.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  7. #22
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Did you put the previous code in the Current event of the form?
    Code:
    If Not IsNull(Me.operater_p) And Not IsNull(Me.potpis_operater) Then
           Me.operater_p.Enabled =False
           Me.potpis_operater.Enabled=False
    Else
          Me.operater_p.Enabled =True
          Me.potpis_operater.Enabled=True
    End iF
    The code above needs to go in the Current event of the form in order to properly enable or disable them for each record (and check for the proper control names).
    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  8. #23
    santon's Avatar
    santon is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    44
    Quote Originally Posted by Gicu View Post
    Code:
    If Not IsNull(Me.operater_p) And Not IsNull(Me.potpis_operater) Then
           Me.operater_p.Enabled =False
           Me.potpis_operater.Enabled=False
    Else
          Me.operater_p.Enabled =True
          Me.potpis_operater.Enabled=True
    End iF
    The code above needs to go in the Current event of the form in order to properly enable or disable them for each record (and check for the proper control names).
    Cheers,

    Thank you so much for all your help guys.
    Ok, this is the code in that form.

    Code:
    Option Compare DatabaseOption Explicit
    
    
    
    
    Private Sub Form_Current()
    If Not IsNull(Me.operater_p) And Not IsNull(Me.potpis_operater) Then
           Me.[operater combo 9 p].Enabled = False
           Me.potpis_operater.Enabled = False
    Else
          Me.[operater combo 9 p].Enabled = True
          Me.potpis_operater.Enabled = True
    End If
    End Sub
    
    
    Private Sub potpis_operater_AfterUpdate()
    
    
    Dim Username As String
        Dim strSQL As String
        Dim strMsg As String
        Dim dbs As DAO.Database
        Dim rst As DAO.Recordset
        Dim password_check As Integer
        
        Username = Form_CO_pakiranje_SD14.operater_p
        Set dbs = CurrentDb()
        strSQL = "SELECT password FROM Evidencija_radnika WHERE ime_prezime = '" & Username & "';"
        Set rst = dbs.OpenRecordset(strSQL)
        password_check = rst![Password]
        rst.Close
        
        If CInt(Form_CO_pakiranje_SD14!potpis_operater) <> password_check Then
        strMsg = Username & ", niste unijeli tocan PIN!"
            MsgBox strMsg
            Form_CO_pakiranje_SD14!potpis_operater = Null 'Vlad you want to make the control Null not empty string ""
             Me.[operater combo 9 p].Enabled = True
           Me.potpis_operater.Enabled = True
    
    
    
    
        Else
            'Form_CO_pakiranje_SD14!potpis_operater = password_check 'Vlad don't need this as they are already equal otherwise you won't get here
            strMsg = Username & ", uspjesno potvrden PIN!"
            MsgBox strMsg
            Me.[operater combo 9 p].Enabled = False
            Me.potpis_operater.Enabled = False
    
    
    
    
        End If
        
        Set rst = Nothing
        Set dbs = Nothing
        
    End Sub
    It is working now, but when you enter a wrong PIN, first it displays message that pin is incorrect, then this error:

    Click image for larger version. 

Name:	2.JPG 
Views:	17 
Size:	23.0 KB 
ID:	43663

    Click image for larger version. 

Name:	Untitled.jpg 
Views:	16 
Size:	41.0 KB 
ID:	43664

    Also, is it too much trouble adding that after selecting the name on the combobox it is strictly required to enter the pin immediately?
    That is why I was trying with modal form

  9. #24
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Can you check the name of the control where you enter the PIN (not the field or control source, but the name of the actual control). Change the code to match that.
    You can do the last thing you ask by making sure the tab order is set that the focus goes to the PIN from the operator combo box and adding code in the BeforeUpdate event of the PIN to check if the PIN was entered. That event has a Cancel argument that you use to force the user to enter a value:
    https://documentation.help/MS-Access...foreUpdate.htm
    http://www.databasedev.co.uk/confirm-record-update.html

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  10. #25
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Just an FYI,
    Code:
    Form_CO_pakiranje_SD14!potpis_operater = Null
    You should never reference a form using the above in RED. This is how Access (internally) is able to differentiate a form named "CO_pakiranje_SD14" and a report named "CO_pakiranje_SD14".

    It is better to have different names for objects. I use a prefix for the different objects : "tbl", "qry", "frm" and "rpt".

  11. #26
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Hi Steve, I think the form's name is CO_pakiranje_SD14 and Form_ is there to reference the open instance (should really be Me. as the code is running in that form's module).

    https://www.tek-tips.com/viewthread.cfm?qid=1785126

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  12. #27
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Hi Vlad,
    Somewhere (I lost the reference - a couple of HHD crashes ago ), I read it was not a good/accepted way of referencing a form object.
    The article link you posted seems to lean toward not using "FORM_" nomenclature. And the only place I've see "Form_" is in the IDE.
    But I am going to study this more.....

    Thanks for the link.

    Steve

  13. #28
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    I am not saying is good, that was part of OP's original attempt and I've just left it like that as it should work.

    Cheers,
    Vlad
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  14. #29
    santon's Avatar
    santon is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Dec 2020
    Posts
    44
    Quote Originally Posted by Gicu View Post
    Can you check the name of the control where you enter the PIN (not the field or control source, but the name of the actual control). Change the code to match that.

    It is a textbox called potpis_operater. Control source is also called potpis_operater. I've tried changing the name of control, got the same error

    Click image for larger version. 

Name:	TEXT BOX.JPG 
Views:	13 
Size:	12.5 KB 
ID:	43672

  15. #30
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,125
    Can you please try:

    Me.potpis_operater=Null

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Page 2 of 3 FirstFirst 123 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Employees Example
    By Mickjav in forum Code Repository
    Replies: 1
    Last Post: 07-06-2020, 12:35 PM
  2. Replies: 11
    Last Post: 04-03-2020, 10:36 PM
  3. How to assign employees
    By rjayb118 in forum Access
    Replies: 5
    Last Post: 09-26-2016, 05:19 PM
  4. Replies: 1
    Last Post: 01-31-2014, 11:03 PM
  5. Replies: 1
    Last Post: 08-23-2013, 07:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums