error 3270 property not found (1 Viewer)

AngelMiguel

New member
Local time
Today, 11:45
Joined
Nov 2, 2018
Messages
11
Greetings,

Problem: error 3270 property not found
Explanation: When the error occurs it does not jump to the error handling line.
Hardware: 64 bits
Software: win64 + office365


Function GetPropertyString(PropertyName As String) As String
Dim prp As DAO.Property
On Error GoTo Property_Errors

GetPropertyString = CurrentDb.Properties(PropertyName)

On Error GoTo 0
Exit Function

Property_Errors:
If Err = 3270 Then
Set prp = CurrentDb.CreateProperty(PropertyName, dbText, " ", False)
CurrentDb.Properties.Append prp
GetPropertyString = " "
Else
MsgBox "Property creation error, no. : " & Err, vbCritical, " Balances".
End If
End Function
 

isladogs

MVP / VIP
Local time
Today, 19:45
Joined
Jan 14, 2017
Messages
18,213
It works for me. Try stepping through the code for both existing properties and ones that don't yet exist.
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:45
Joined
Sep 21, 2011
Messages
14,264
You code does not even compile?
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:45
Joined
Sep 21, 2011
Messages
14,264
Well it does for me, only when the property does not exist?
Have you walked though your code?
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:45
Joined
Sep 21, 2011
Messages
14,264
Greetings,
The code is debugged. There are no errors.
Well there is an error in the code you posted, and it was highlighted when I pasted the code into a module, though that would not cause this problem I would have thought?
 

Gasman

Enthusiastic Amateur
Local time
Today, 19:45
Joined
Sep 21, 2011
Messages
14,264
There is a full stop at the end of the MSGBOX line and that came up red in my 2007?
Removing it allowed me to compile the function?
 

isladogs

MVP / VIP
Local time
Today, 19:45
Joined
Jan 14, 2017
Messages
18,213
Ah yes. Sorry - I forgot I had deleted that!
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 14:45
Joined
May 21, 2018
Messages
8,527
Code:
Public Sub TestGet()
  Debug.Print GetPropertyString("Cat")
  CurrentDb.Properties("Cat") = "meow"
  Debug.Print GetPropertyString("Cat")
End Sub
Works fine result
Code:
meow
 

Users who are viewing this thread

Top Bottom