Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Duplication on a Subform

Status
Not open for further replies.

Shirley

Programmer
Aug 30, 1999
198
US
Does anyone know how to set up a procedure that will check the field in a subform for duplication of Code, and allow the entry if that code has and ending date. For example the program I am designing have BCodes which are benefits codes. The subform is linked to the main form is by SSN. On the subform the user doesn't want the BCode to be duplicated unless the Ending Date is on the previous BCode, then the BCode can be duplicated. If anyone have a suggestion, please let me know I would greatly appreciate it.
 
Does anyone know how to fix this problem, this is the only thing left to fix this program.&nbsp;&nbsp;I would greatly appreciate it.<br><br>Shirley
 
I'm not sure I understand the question.<br><br>Could you email an example .mdb?<br><br>Please make sure there is no important &quot;secret&quot; data included in the database (like real SSN's). <p>Jim Conrad<br><a href=mailto:JimConrad@Consultant.com>JimConrad@Consultant.com</a><br><a href= > </a><br>
 
Jim<br><br>I have tried twice to sent you the sample but for some reason I can not send it to you, but let me explain more. <br><br>Key Log Out Table<br>Fields Name<br><br>TransID<br>SiteNumber<br>KeyNumber<br>EmployeeID<br>IssuedDate<br>ReturnedDate<br><br>This table is linked to Site Table, Key Table and Employee Table<br><br>On this table there is a site number and a key number assigned to each key, I would like to let the user know if that particular key have already been assigned to someone else because it doesn't have a returned date.&nbsp;&nbsp;But if there is a return date then the user may issue that key out again.&nbsp;&nbsp;The problem is that I'm not a very good VB coding person, but I'm good at developing database.&nbsp;&nbsp;I can not make those three fields the primary key because the return date is sometimes null.&nbsp;&nbsp;I have tried to make the other two fields primary, but then it will not allow me to ever use the site number and key number again.&nbsp;&nbsp;I've even tried to set up a unique index, but I did not know how the coding for that would go.&nbsp;&nbsp;So if you have any ideas, please let me
 
I'm still trying to figure this problem out and I really need some help, if anyone have a suggestion please let me know.
 
It sounds like you want to check to see if there is a transaction with a particular KeyNumber where the ReturnedDate is null?&nbsp;&nbsp;And if there is one to display a message to the user?<br><br>If your form contains a control called KeyNumber...<br><br><FONT FACE=monospace><br>Sub KeyNumber_BeforeUpdate(Cancel as Integer)<br><br>&nbsp;&nbsp;&nbsp;Dim KeyNotReturnedCount as Long<br><br>&nbsp;&nbsp;&nbsp;KeyNotReturnedCount = DCount(&quot;*&quot;,&quot;Key Log Out Table&quot;,&quot;KeyNumber =&quot; & Me!KeyNumber & &quot; AND ReturnedDate Is Null&quot;)<br><br>&nbsp;&nbsp;&nbsp;If KeyNotReturnedCount = 0 Then<br>&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;allow process to continue<br>&nbsp;&nbsp;&nbsp;Else<br>&nbsp;&nbsp;&nbsp;'&nbsp;&nbsp;stop process<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox &quot;Key still not returned&quot;<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel = True<br>&nbsp;&nbsp;&nbsp;End If<br>&nbsp;&nbsp;<br>End Sub<br></font> <p>Jim Conrad<br><a href=mailto:JimConrad@Consultant.com>JimConrad@Consultant.com</a><br><a href= > </a><br>
 
Thanks Jim that seems to give me a step in the right direction.
 
Jim<br><br>I have tried and tried and it is not working.&nbsp;&nbsp;Maybe because each site number have 40 keynumbers from 1-40.&nbsp;&nbsp;The SiteNumber and KeyNumber needs to be checked , and then the&nbsp;&nbsp;ReturnDate need to be Null.&nbsp;&nbsp;The process is enter sitenumber then keynumber then do the check.&nbsp;&nbsp;Wouldn't the check need to be AfterUpdate and If cancel = True then delete record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top