Form not recognizing record added via SQL statement

  • Thread starter Cyberwolf0000 via AccessMonster.com
  • Start date
C

Cyberwolf0000 via AccessMonster.com

I have a table that has data entered in 2 ways. One way is when it is
entered on a subform of another form. The other is a stand-alone form. The
underlying table structure is as follows:


ReasonCodes - ReasonCodeID(PK)
RPPCauseInfo - RPPCauseInfoID(PK) - ReasonCodeID(FK)

I have a one-to-many relationship between ReasonCodes(One) and RPPCauseInfo
(Many).

When data is entered via the subform everything works fine. But, when I have
the stand-alone form open, I have Code that adds a record to the ReasonCodes
table using a SQL INSERT INTO statement. The record gets added fine, but
when I go to move away from the record I get an error "The Microsoft Jet
database engine cannot find a record in the table 'ReasonCodes' with key
matching field(s) 'ReasonCodeID'" I have tried doing a requery on the form
but that did not help. I believe it is because of the One-To-Many
relationship. That is why I add a record to the ReasonCodes table to enforce
the integrity. Is there a way to requery the ReasonCodes table so that the
record is recognized?

Can anyone tell me why this happens?

--
James B Gaylord
For the Wolf comes the strength of the Pack,
For the Pack comes the strength of the Wolf,
-R. Kipling
Office 2003 on Win XP SP2
 
T

tkelley via AccessMonster.com

Can you post your SQL statement?
I have a table that has data entered in 2 ways. One way is when it is
entered on a subform of another form. The other is a stand-alone form. The
underlying table structure is as follows:

ReasonCodes - ReasonCodeID(PK)
RPPCauseInfo - RPPCauseInfoID(PK) - ReasonCodeID(FK)

I have a one-to-many relationship between ReasonCodes(One) and RPPCauseInfo
(Many).

When data is entered via the subform everything works fine. But, when I have
the stand-alone form open, I have Code that adds a record to the ReasonCodes
table using a SQL INSERT INTO statement. The record gets added fine, but
when I go to move away from the record I get an error "The Microsoft Jet
database engine cannot find a record in the table 'ReasonCodes' with key
matching field(s) 'ReasonCodeID'" I have tried doing a requery on the form
but that did not help. I believe it is because of the One-To-Many
relationship. That is why I add a record to the ReasonCodes table to enforce
the integrity. Is there a way to requery the ReasonCodes table so that the
record is recognized?

Can anyone tell me why this happens?
 
C

Cyberwolf0000 via AccessMonster.com

strSQL = "SELECT ReasonCodeID " & _
"FROM ReasonCodes " & _
"WHERE ReprintID=" & rec2!ReprintID & " AND Reason='Rejected
Preprint' " & _
"AND ReasonFreq=1 AND ReasonImps=" & rec!NetImps & " AND " & _
"ReasonComments='This roll was rejected by the Roll to Roll
Department';"
Set rec3 = db.OpenRecordset(strSQL)
Me.ReasonCodeID = rec3!ReasonCodeID

Can you post your SQL statement?
I have a table that has data entered in 2 ways. One way is when it is
entered on a subform of another form. The other is a stand-alone form. The
[quoted text clipped - 18 lines]
Can anyone tell me why this happens?

--
James B Gaylord
For the Wolf comes the strength of the Pack,
For the Pack comes the strength of the Wolf,
-R. Kipling
Office 2003 on Win XP SP2
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top