Smiley 3636
New member
- Local time
- Tomorrow, 03:11
- Joined
- Oct 15, 2023
- Messages
- 17
Hi I have a problem, an would appreciate help with the folowing.
I need to extract the first three letters from a clients name and add a unique index number to it, as the primary key. For example
ID: FLI0001-BIZ
Type: Company
Name: Flintstone Pty Ltd
Type can be Individual (IND), while Sole Pro, Partnership, Company, Trust, SMSF & Non Profits are (BIZ)
Table:
[PK] Client Type: Client Name
FLI0001-BIZ Company Flintstone Pty Ltd
FLI0002-IND Individual Flintstone, Fred
CON0001-BIZ Partnership Connolly AM & JE
Code: (that i don't seem to get to work)
Function clientidPK()
Dim InB
Dim dbs As Database
Dim rstProducts As Recordset
Dim rstCustomers As Recordset
Dim strSeek As String
Dim varBookmark As Variant
Dim a As Integer
Set dbs = CurrentDb
Set rstProducts = dbs.OpenRecordset("dbtClientList")
InB = Left([Name1], 3) & Format(10000, "#0000")
a = 0
With rstProducts
.Index = "Client"
strSeek = .NoMatch
Do While True
If strSeek <> "" Then
strSeek = .NoMatch
a = a + 1
ElseIf strSeek = "" Then
Exit Do
End If
bSeekMatch rstProducts, strSeek, InB, a
Loop
.Close
End With
dbs.Close
End Function
Sub bSeekMatch(rstTemp As Recordset, intSeek As String, InB, a)
Dim varBookmark As Variant
Dim strMewssage As String
With rstTemp
varBookmark = .Bookmark
.Seek "=", InB
If .NoMatch Then
.Bookmark = varBookmark
intSeek = ""
[Clientrid] = InB
Else
InB = Left([Name1], 3) & Format(10000, "#0000") + a
End If
End With
End Sub
Public Function Form()
End Function
I need to extract the first three letters from a clients name and add a unique index number to it, as the primary key. For example
ID: FLI0001-BIZ
Type: Company
Name: Flintstone Pty Ltd
Type can be Individual (IND), while Sole Pro, Partnership, Company, Trust, SMSF & Non Profits are (BIZ)
Table:
[PK] Client Type: Client Name
FLI0001-BIZ Company Flintstone Pty Ltd
FLI0002-IND Individual Flintstone, Fred
CON0001-BIZ Partnership Connolly AM & JE
Code: (that i don't seem to get to work)
Function clientidPK()
Dim InB
Dim dbs As Database
Dim rstProducts As Recordset
Dim rstCustomers As Recordset
Dim strSeek As String
Dim varBookmark As Variant
Dim a As Integer
Set dbs = CurrentDb
Set rstProducts = dbs.OpenRecordset("dbtClientList")
InB = Left([Name1], 3) & Format(10000, "#0000")
a = 0
With rstProducts
.Index = "Client"
strSeek = .NoMatch
Do While True
If strSeek <> "" Then
strSeek = .NoMatch
a = a + 1
ElseIf strSeek = "" Then
Exit Do
End If
bSeekMatch rstProducts, strSeek, InB, a
Loop
.Close
End With
dbs.Close
End Function
Sub bSeekMatch(rstTemp As Recordset, intSeek As String, InB, a)
Dim varBookmark As Variant
Dim strMewssage As String
With rstTemp
varBookmark = .Bookmark
.Seek "=", InB
If .NoMatch Then
.Bookmark = varBookmark
intSeek = ""
[Clientrid] = InB
Else
InB = Left([Name1], 3) & Format(10000, "#0000") + a
End If
End With
End Sub
Public Function Form()
End Function