stlinkcriteria (1 Viewer)

Pavczech

Registered User.
Local time
Today, 15:04
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
 

Isskint

Slowly Developing
Local time
Today, 15:04
Joined
Apr 25, 2012
Messages
1,302
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)"
 

vbaInet

AWF VIP
Local time
Today, 15:04
Joined
Jan 22, 2010
Messages
26,374
Is the table bound to stNoExist form?
 

Pavczech

Registered User.
Local time
Today, 15:04
Joined
Jul 11, 2012
Messages
41
Sorry but not sure what stNoExist mean.
Thanks
 

vbaInet

AWF VIP
Local time
Today, 15:04
Joined
Jan 22, 2010
Messages
26,374
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.
 

Pavczech

Registered User.
Local time
Today, 15:04
Joined
Jul 11, 2012
Messages
41
Hi
Yes it is, but is there a way to link it if it wouldn't be.
Thanks
 

vbaInet

AWF VIP
Local time
Today, 15:04
Joined
Jan 22, 2010
Messages
26,374
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 (Users: 0, Guests: 1)

Top Bottom