Reputation: 849
I have two tables that I am concatenating fields from. The first table (tbl1Artwork) primary key (ID), has a data type of AutoNumber and a format of "SA"0000. The second table (tbl0Artist), field (ArtistSKU) is formatted as ShortText. I am running the code shown as an AfterUpdate in a form. The expected result is "SA0008DL1" (the DL1 is concatenated from the ArtistSKU field). The actual result is 8DL1. This is confusing as SA0008 is properly stored in the ID field of table tbl1Artwork.
Option Compare Database
Private Function UpdateArtworkSKU()
Me.ArtworkSKU = Me.txtArtworkID & Me.cboArtistID.Column(3)
End Function
Upvotes: 0
Views: 37
Reputation: 4099
Although you have formatted the primary key field to look like "SA0008", the actual value being stored is just 8. You would therefore need to amend the code to read:
Me.ArtworkSKU = "SA" & Format(Me.txtArtworkID,"0000") & Me.cboArtistID.Column(3)
As an aside, using the primary key when it is an autonumber for anything other than joining data behind the scenes is normally a bad idea.
Regards,
Upvotes: 1