stlinkcriteria

Pavczech

Registered User.
Local time
Today, 20:12
Joined
Jul 11, 2012
Messages
41
Hello
I have working code, but i need bit tweek.
So There is a table "Visitors Book - Personal", with Fields: "ID","Unique Code","Surname","First Name",etc

Now! When I press ENTER button it check if exists, ( It Works ), on the end is little code which takes ID and changes to "Unique Code" that is fine too. !!! What I need is somehow to transfer The "Unique Code" to another table called "Visitors Book - Visits". I have tried to create croostable query but didn't work. Could that be linking criteria or Another Link. Please Help!!!

Private Sub CommandENTER_Click()
Dim stExist As String
Dim stNoExist As String
Dim stLinkCriteria As String

Dim I As Integer

I = DCount("[First Name]", "[Visitors Book - Personal]", "[First Name] ='" & Forms![Visitors Book In]![First Name] & "'")
Y = DCount("[Surname]", "[Visitors Book - Personal]", "[Surname] ='" & Forms![Visitors Book In]![Surname] & "'")

If I > 0 And Y > 0 Then
MsgBox "Already exist!"
Else
stNoExist = "Confirmation noexist"
DoCmd.OpenForm stNoExist, , , stLinkCriteria
End If
Me.UniqueCode = "Chill" & [ID] + 1
End Sub


Thanks
 
run an append query. something like;

"INSERT INTO [Visitors Book - Visits] (ID, [Unique Code], Surname, Firstname, etc) VALUES (" & me.ID & ", '" & me.[unique code] & ";, '" & me.surname & "', '" & me.firstname & "', etc)"
 
Is the table bound to stNoExist form?
 
If I > 0 And Y > 0 Then
MsgBox "Already exist!"
Else
stNoExist = "Confirmation noexist"
DoCmd.OpenForm stNoExist, , , stLinkCriteria
End If
Me.UniqueCode = "Chill" & [ID] + 1
End Sub
Sorry I should have said the "Confirmation noexist" form. See your code in red.
 
Hi
Yes it is, but is there a way to link it if it wouldn't be.
Thanks
 
Yes there are ways of doing that, but what I don't understand is why you want to create a unique ID when the form is opened??
 

Users who are viewing this thread

Back
Top Bottom