Invalid Use of Property on Click comand? (1 Viewer)

GLese

Registered User.
Local time
Today, 09:02
Joined
Feb 13, 2018
Messages
52
Code:
Option Compare Database
Option Explicit
Private Sub btnClosefrmRPRLLogin_Click()
  DoCmd.Close
    'Closes Form on Click
End Sub
Private Sub btnLoginPaperwork_Click()
    DateTimeIn
    'Timestamps DateTimeIn Field
    MsgBox "Repack/Relabel Paperwork Sucessfully Logged In", vbOKOnly, "Thank You!"
    DoCmd.Close
    
End Sub
The problem line is: Private Sub btnLoginPaperwork_Click()

Being so new to VB and Access, I'm not sure why I'm getting this error. I just separated out the DateTimeIn code into a separate module (Public Sub) so I can use it in multiple places.

Here is that Module:
Code:
Public Sub DateTimeIn()
With CodeContextObject
.DateTimeIn = Now()
Beep
End With
End Sub

Help???
 
Last edited:

1268

Registered User.
Local time
Today, 08:02
Joined
Oct 11, 2012
Messages
44
Code:
Option Compare Database
Option Explicit
Private Sub btnClosefrmRPRLLogin_Click()
  DoCmd.Close
    'Closes Form on Click
End Sub
Private Sub btnLoginPaperwork_Click()
    DateTimeIn
    'Timestamps DateTimeIn Field
    MsgBox "Repack/Relabel Paperwork Sucessfully Logged In", vbOKOnly, "Thank You!"
    DoCmd.Close
    
End Sub
The problem line is: Private Sub btnLoginPaperwork_Click()

Being so new to VB and Access, I'm not sure why I'm getting this error. I just separated out the DateTimeIn code into a separate module (Public Sub) so I can use it in multiple places.

Here is that Module:
Code:
Public Sub DateTimeIn()
With CodeContextObject
.DateTimeIn = Now()
Beep
End With
End Sub

Help???

Try

Function DateTimeIn() as string

DateTimeIn = now()

End function

That should get the stamp you want but you have to do something with it. Like me.textbox12 = DateTimeIn within your login procedure...

Sent from my SM-G950U using Tapatalk
 

GLese

Registered User.
Local time
Today, 09:02
Joined
Feb 13, 2018
Messages
52
Try

Function DateTimeIn() as string

DateTimeIn = now()

End function

That should get the stamp you want but you have to do something with it. Like me.textbox12 = DateTimeIn within your login procedure...

Sent from my SM-G950U using Tapatalk

So if I set the module to:

Code:
Function DateTimeIn() As String
DateTimeIn = Now()
End Function

I get the same error. But if I put the main button code as:

Code:
Public Sub btnLoginPaperwork_Click()
    With CodeContextObject
    .DateTimeIn = Now()
    'Timestamps DateTimeIn Field
    Beep
End With
    MsgBox "Repack/Relabel Paperwork Sucessfully Logged In", vbOKOnly, "Thank You!"
    'Popup to confirm data entry to Operator
    DoCmd.Close
    
End Sub

With no modules being called, then everything works.
 

1268

Registered User.
Local time
Today, 08:02
Joined
Oct 11, 2012
Messages
44
So if I set the module to:

Code:
Function DateTimeIn() As String
DateTimeIn = Now()
End Function

I get the same error. But if I put the main button code as:

Code:
Public Sub btnLoginPaperwork_Click()
    With CodeContextObject
    .DateTimeIn = Now()
    'Timestamps DateTimeIn Field
    Beep
End With
    MsgBox "Repack/Relabel Paperwork Sucessfully Logged In", vbOKOnly, "Thank You!"
    'Popup to confirm data entry to Operator
    DoCmd.Close
    
End Sub

With no modules being called, then everything works.

Keep your code and change datetimein to a public function.

Sent from my SM-G950U using Tapatalk
 

Users who are viewing this thread

Top Bottom