Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 08-12-2012, 11:53 AM   #1
Pavczech
Newly Registered User
 
Join Date: Jul 2012
Posts: 41
Thanks: 7
Thanked 0 Times in 0 Posts
Pavczech is on a distinguished road
stlinkcriteria

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

Pavczech is offline   Reply With Quote
Old 08-12-2012, 12:58 PM   #2
Isskint
Slowly Developing
 
Isskint's Avatar
 
Join Date: Apr 2012
Location: Wiltshire, UK
Posts: 1,301
Thanks: 124
Thanked 311 Times in 304 Posts
Isskint will become famous soon enough
Re: stlinkcriteria

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)"
__________________
Isskint, i get satisfaction out of helping others
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


Success is the sum of small efforts, repeated day in and day out
Isskint is offline   Reply With Quote
Old 08-13-2012, 03:09 AM   #3
vbaInet
AWF VIP
 
Join Date: Jan 2010
Location: U.K.
Posts: 26,374
Thanks: 0
Thanked 2,423 Times in 2,389 Posts
vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all
Re: stlinkcriteria

Is the table bound to stNoExist form?

vbaInet is offline   Reply With Quote
Old 08-13-2012, 04:16 AM   #4
Pavczech
Newly Registered User
 
Join Date: Jul 2012
Posts: 41
Thanks: 7
Thanked 0 Times in 0 Posts
Pavczech is on a distinguished road
Re: stlinkcriteria

Sorry but not sure what stNoExist mean.
Thanks
Pavczech is offline   Reply With Quote
Old 08-13-2012, 04:48 AM   #5
vbaInet
AWF VIP
 
Join Date: Jan 2010
Location: U.K.
Posts: 26,374
Thanks: 0
Thanked 2,423 Times in 2,389 Posts
vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all
Re: stlinkcriteria

Quote:
Originally Posted by Pavczech View Post
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.
vbaInet is offline   Reply With Quote
Old 08-13-2012, 11:25 AM   #6
Pavczech
Newly Registered User
 
Join Date: Jul 2012
Posts: 41
Thanks: 7
Thanked 0 Times in 0 Posts
Pavczech is on a distinguished road
Re: stlinkcriteria

Hi
Yes it is, but is there a way to link it if it wouldn't be.
Thanks
Pavczech is offline   Reply With Quote
Old 08-14-2012, 06:16 AM   #7
vbaInet
AWF VIP
 
Join Date: Jan 2010
Location: U.K.
Posts: 26,374
Thanks: 0
Thanked 2,423 Times in 2,389 Posts
vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all vbaInet is a name known to all
Re: stlinkcriteria

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??


vbaInet is offline   Reply With Quote
Reply

Tags
button , code , crosstab query , stlinkcriteria , vba

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
stLinkCriteria *Pete* Forms 3 12-15-2006 01:15 AM
stLinkcriteria ruchijigs Forms 14 02-02-2006 02:09 PM
stLinkCriteria Treason General 1 01-22-2003 12:06 PM
stlinkcriteria Geoff Codd Modules & VBA 3 03-15-2002 02:03 PM
[SOLVED] stLinkCriteria khefner Modules & VBA 2 01-17-2002 02:11 PM




All times are GMT -8. The time now is 04:07 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World