To comp.databases. ms-access:
In the VBA code behind a form, I would like to create a string
variable, composed of the names of the field(s) in the primary key of
the table which is the "RecordSour ce" of the given form. For example,
if my string variable is called "PriKeyFiel ds", and the primary key of
the RecordSource table is (Field01, Field02, Field03), then I would
like PriKeyFields to be set to the string "Field01 Field02 Field03".
I am using Microsoft Access 2003, on a PC running Windows XP
Professional.
Is there any way to do this? Thanks very much!
--Tom
email: frethoa AT aol DOT com 2 6909
On 2 Feb 2007 14:00:25 -0800, "Tom_F" <fr*****@aol.co mwrote:
>To comp.databases. ms-access:
In the VBA code behind a form, I would like to create a string variable, composed of the names of the field(s) in the primary key of the table which is the "RecordSour ce" of the given form. For example, if my string variable is called "PriKeyFiel ds", and the primary key of the RecordSource table is (Field01, Field02, Field03), then I would like PriKeyFields to be set to the string "Field01 Field02 Field03".
I am using Microsoft Access 2003, on a PC running Windows XP Professional .
Is there any way to do this? Thanks very much!
--Tom
email: frethoa AT aol DOT com
The following function will return the field list of the PK index of the passed
table. It should give you something to work with.
?fFindPrimaryKe yFields(Current DB.TableDefs("M yTable"))
+Field01;+Field 01;+Field03
Function fFindPrimaryKey Fields(tdf As TableDef) As String
Dim idx As Index
On Error GoTo HandleIt
For Each idx In tdf.Indexes
If idx.Primary Then
fFindPrimaryKey Fields = idx.Fields
GoTo OutHere
End If
Next idx
OutHere:
Set idx = Nothing
Exit Function
HandleIt:
Select Case Err
Case 0
Resume Next
Case Else
Beep
MsgBox Err & " " & Err.Description , vbCritical + vbOKOnly, "Error"
fFindPrimaryKey Fields = vbNullString
Resume OutHere
End Select
End Function
Wayne Gillespie
Gosford NSW Australia
Mr. Gillespie --
thanks so much, this worked very well! I put your function in a
module, where it could be called from any given form. Then, in order
to actually create a VBA string variable ("pri_key") consisting of the
primary-key fields of a form's RecordSource, I added this piece of
code to each form (as part of a BeforeUpdate "Private Sub"):
-----------------------------------------------------------------------------------------------
Dim db As DAO.Database
Set db = CurrentDb
Dim tbld As TableDef
Dim pri_key As String
Dim recsource As String
recsource = Me.RecordSource
Set tbld = db.TableDefs(re csource)
pri_key = fFindPrimaryKey Fields(tbld)
Debug.Print
Debug.Print "pri_key: "; pri_key
-----------------------------------------------------------------------------------------------
Thank you again! Best,
--Tom
email: frethoa AT aol DOT com
On Feb 2, 7:09 pm, Wayne Gillespie <best...@NOhotm ailSPAM.com.au>
wrote:
On 2 Feb 2007 14:00:25 -0800, "Tom_F" <fret...@aol.co mwrote:
To comp.databases. ms-access:
In the VBA code behind a form, I would like to create a string
variable, composed of the names of the field(s) in the primary key of
the table which is the "RecordSour ce" of the given form. For example,
if my string variable is called "PriKeyFiel ds", and the primary key of
the RecordSource table is (Field01, Field02, Field03), then I would
like PriKeyFields to be set to the string "Field01 Field02 Field03".
I am using Microsoft Access 2003, on a PC running Windows XP
Professional.
Is there any way to do this? Thanks very much!
--Tom
email: frethoa AT aol DOT com
The following function will return the field list of the PK index of the passed
table. It should give you something to work with.
?fFindPrimaryKe yFields(Current DB.TableDefs("M yTable"))
+Field01;+Field 01;+Field03
Function fFindPrimaryKey Fields(tdf As TableDef) As String
Dim idx As Index
On Error GoTo HandleIt
For Each idx In tdf.Indexes
If idx.Primary Then
fFindPrimaryKey Fields = idx.Fields
GoTo OutHere
End If
Next idx
OutHere:
Set idx = Nothing
Exit Function
HandleIt:
Select Case Err
Case 0
Resume Next
Case Else
Beep
MsgBox Err & " " & Err.Description , vbCritical + vbOKOnly, "Error"
fFindPrimaryKey Fields = vbNullString
Resume OutHere
End Select
End Function
Wayne Gillespie
Gosford NSW Australia
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Andrew V. Romero |
last post by:
I have been working on a function which makes it easier for me to pull
variables from the URL. So far I have:
<script language="JavaScript">
var variablesInUrl;
var vArray = new Array();
function loadUrlVariables()
{
varString = location.search;
|
by: I_AM_DON_AND_YOU? |
last post by:
There is one more problem I am facing but didn't get the solution. In my
Setup Program I am not been able to create 2 things (when the program is
intalled on the client machine ) : (1) create shortcut to my program/utility
(2) Entry in Windows' Start --> Program Menu.
Actually in my VB.Net solution I have two projects (1) MYPROGRAM (2)
MYPROGRAM_INSTALLER. MYPROGRAM is a "Windows Application".
MYPROGRAM_INSTALLER is a "SetUp Wizard"...
|
by: GrandpaB |
last post by:
I would appreciate assistance learning how to create a Desktop shortcut in my
setup project.
In the left pane of the Setup/File System window I right-clicked User's
Desktop. From the contex menu I clicked Create Shortcut to User's Desktop.
In the right pane of the setup/File System window the object Shortcut to
User's Desktop appeared. When I selected the object and checked it's
properties the Target and WorkingFolder are User's...
|
by: Jake Barnes |
last post by:
Using javascript closures to create singletons to ensure the survival
of a reference to an HTML block when removeChild() may remove the last
reference to the block and thus destory the block is what I'm hoping to
achieve.
I've never before had to use Javascript closures, but now I do, so I'm
making an effort to understand them. I've been giving this essay a
re-read:
http://jibbering.com/faq/faq_notes/closures.html
|
by: Deecrypt |
last post by:
Hi,
I would like to pickup a value from a textbox and make it available to
be used by every method within a class. I havent done anything like
this since VB 6. Any suggestions?
Cheers
Khurram
| |
by: Schraalhans Keukenmeester |
last post by:
I have some C functions (with variable length argument lists) that use
void pointers as arguments.
Is there a way to determine at runtime what type of parameter is
actually passed on to the function? PHP and my oldskool turbopascal
provide a typeof() function, but my C compiler (gcc 3.4.1) does not seem
to provide this function. Perhaps someone crafted a library with some
smart code able to inspect the variable passed to a certain...
|
by: John |
last post by:
Which variable type (c#) can whole the largest whole number? I know this
sounds silly but as double and decimal are made for numbers with decimals I
am not sure.
Also if anybody knows of any library for .NET that would allow me to deal
with **VERY** large whole numbers.
Thanks in advance
JT.
|
by: John Passaniti |
last post by:
(Note: This is not the same message I posted a week or so ago. The
problem that prevented my previous attempt to work was a silly error in
the template system I was using. This is a problem involving variable
scope in JavaScript.)
I have a lot of code that generates HTML on the fly. This code has tags
with id attributes derived from variables. A small example:
blah('<span id="' + dev + '_' + mod + '">...</span>');
|
by: sanghavi |
last post by:
how to create a set up project in vb.net..how to run an application on a different machine
|
by: illegal.prime |
last post by:
Hi all, I'm getting unexpected results when trying to preload
assemblies into an AppDomain I'm creating. Upon creation of the
AppDomain - I attach an AssemblyResolve to both my current AppDomain
and the new AppDomain I create.
I copy all the assemblies/dlls into a new directory and then try
loading them all into the new AppDomain using the following:
private void LoadAssembliesFromDirectory(AppDomain appDomain, string
directory)
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |