Sorry for this stupid question. Being a novice when I had to put my project down for several months I'm fuzzy on writing my code again.
Anyway, in my project I have a table of Zipcodes [sysdta_ZipCodes] and a table of State Codes [sysdta_FIPSStates]. I then have a table that relates them [sysctlZipFIPSState].
My table [sysctlZipFIPSState] has the PKs from those two tables [ZipID] and [FIPSStateCode] set as primary keys.
I am trying to write code that looks at the recordset for the table [sysctlZipFIPSState] to see if that combo already exits before it tries to add it again and gives the user all that cryptic MS error that freaks them out.
Dim lngZipID As Long, lngFIPSState As Long
Dim rst1 As DAO.Recordset, lngCountID As Long
lngZipID = Me.cboSelectZip.Column(0)
lngFIPSState = Me.cboSelectState.Column(0)
Set rst1 = CurrentDb.OpenRecordset("SELECT * FROM sysctl_ZipFIPSState WHERE [ZipID]=" & lngZipID & " AND [FIPSStateCode] =" & lngFIPSState)
lngCountID = Nz(DCount("ZipID", "rst1"), 0)
This doesn't work as you'll know. Am I using this wrong?