Yollem Crumble
New member
- Local time
- Today, 23:18
- Joined
- Dec 11, 2022
- Messages
- 5
I have an access table holding, amongst other things addresses of members. When an address is added or modified I trigger an "after update"
event to correct abbreviations and also to populate another field in the record with a "full address" which is used for many other purposes. The problem I have is that I cannot figure out how to "commit" changes to a field, resulting in write conflict errors.. There are no subforms involved. It is also not a case of two users operating on the field at the same time. Any help with resolving this would be appreciated.
This is the code:
event to correct abbreviations and also to populate another field in the record with a "full address" which is used for many other purposes. The problem I have is that I cannot figure out how to "commit" changes to a field, resulting in write conflict errors.. There are no subforms involved. It is also not a case of two users operating on the field at the same time. Any help with resolving this would be appreciated.
This is the code:
Code:
Private Sub Street1_AfterUpdate()
Dim ans As String
If Me.Dirty Then
Me.Dirty = False
End If
'''''''''''''''''''''''''''''''''Write conflict generated
[Street1] = ckadd([Street1]) ' check street abbreviation
[emailOK] = True 'set a flag field to nenew email data
ans = Log_Change("Street1", [Street1], [Member_Number] )' add a record to log table
If Me.Dirty Then
Me.Dirty = False
End If
[FullAddress] = Fill_FAddress([Member_Number]) 'call function to update a field with the full address
If Me.Dirty Then
Me.Dirty = False
End If
'''''''''''''''''''''''''''''''''Write conflict generated
End Sub
'---------------------------------------------------------------------------
Private Function ckadd(add) As String
Dim last As String
Dim tem As String
Dim aok As Boolean
'check if nul
If Len(add & vbNullString) = 0 Then
add = ""
End If
aok = False
'remove punctuation
tem = Replace(add, ",", "")
add = Trim(tem)
tem = Replace(add, ".", "")
add = Trim(tem)
If Len(add) > 4 Then
last = Right(add, 3)
If last = " St" Then
last = " Street"
aok = True
End If
' And a whole heap of other abbreviations checked for
If last = "ent" Or last = "ace" Or last = "nue" Or last = "ade" Or last = "uit" Or last = "urt" Or last = "ane" _
Or last = "ive" Or last = "eet" Or last = "oad" Or last = "ove" Or last = "ace" Or last = "ose" Or last = "Way" _
Or last = "ews" Or Left(add, 2) = "PO" Or Left(add, 2) = "GP" Then
aok = True
End If
tem = StrConv(Left(add, Len(add) - 3), 3) & last
End If
If Not aok Then
add = InputBox("Please Check Street Name ", , add)
End If
ckadd = Trim(tem)
End Function
'--------------------------------------------------------------------------------------
Function Fill_FAddress(mem) As String
Dim faddress As String
Dim dbgpsmembership As DAO.Database
Dim rsm As Recordset
Set dbgpsmembership = CurrentDb
Set rsm = dbgpsmembership.OpenRecordset("GPSMembers")
rsm.MoveFirst
rsm.FindFirst "[member_Number] = " & mem
If rsm.NoMatch Then GoTo errormem
faddress = rsm("Street1").Value & "; "
If Len(rsm("Street2").Value & vbNulString) <> 0 Then faddress = faddress & rsm("Street2").Value & "; "
faddress = faddress & rsm("Suburb").Value & "; " & rsm("State").Value & " " & rsm("Postcode").Value
faddress = faddress & " " & rsm("Country").Value
Fill_FAddress = faddress
GoTo Endprocess
errormem:
MsgBox ("Error in fill full Address")
Fill_FAddress = ""
Endprocess:
End Function