RainLover
VIP From a land downunder
- Local time
- Tomorrow, 08:06
- Joined
- Jan 5, 2009
- Messages
- 5,039
I always miss the good fights![]()
And this has been a beauty.
The best part is that I won.
I always miss the good fights![]()
I really can't comment.
I failed at SQL Server.
I use MySQL when necessary.
Perhaps you could explain.
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
CurrentDb.TableDefs.Delete stLocalTableName
rain
it may be that this is just about semantics.
maybe i/we are misunderstanding - you seem to be saying that an autonumber key is as good as any other key to determine the uniqueness of a record
i think the point at issue is that an autonumber key is certainly good enough to maintain relatedness between items in tables - and very usefully is also rather more efficient in use than a composite key - but of itself it is insufficient to guarantee the integrity of the data - whereas a correctly chosen composite key is by definition selected in order to maintain integrity.
is that just semantics?
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
And this has been a beauty.
The best part is that I won.![]()
![]()
![]()
![]()
But I have enjoyed the banter dealing with people who refuse to move into the 20th Century.
Tomorrow is another day. I will address this one then.I disagree entirely.
You claimed that a table cannot have two keys. It can, but only one can be the Primary Key. This is quite a different issue from the use of two fields as a composite key.
A year ago I did work in 97 for a Qld Government Department as a contractor.
It was there that I saw this over abundance of Composite Primary Keys. 4 Fields was common place, and sometimes more.
[color=green]'// stLocalTableName: Name of the table that you are creating in the current database[/color]
For Each td In CurrentDb.TableDefs
If td.Name = stLocalTableName Then
CurrentDb.TableDefs.Delete stLocalTableName
End If
Next
I am a college student also and I have been trying for a week to get the composite primary key concept to work. I kept getting a one to one relationship between my parent table and the linking table on the side where the foreign key was listed first in the linking table. Once I did what Pat said I had a composite primary key and two one-to-many relationships. Thank a million.
A good example of WTF code from Microsoft And they always do
Dim db As DAO.Database
Set db = CurrentDb()
"Lets replace one perfectly good object variable with another."
And that waste of space appears in so many other peoples' code.
DBEngine.Workspaces(0).Databases(0)
Set tdf = CurrentDb.TableDefs(0): ? tdf.Name
Set db = Currentdb: Set tdf = db.TableDefs(0): ? tdf.Name
Dim strname as String
Dim strWhere As String
strname = "someformname"
DoCmd.OpenForm strName, , , strWhere
I don't care what Galaxiom says. There are some things that should never happen.
Few practices lauded as "never" in database design actually turn out to be so universally unacceptable as portrayed by the detractor.
Why create a variable at all?
Print CurrentDb.TableDefs(0).Name
Why test code in an artificial environment (the debug window) where the code will not be actually running? Is it faster?
Db is not declared so it won’t work unless we turn off Option Explicit. But who wants to turn off Option Explicit in order to test their code?
I think we all get set in our ways. But I don’t think we get that old that we can’t think.
Option Compare Database
Option Explicit
Public Function DBtest(ByRef db As DAO.Database) As String
DBtest = db.TableDefs(0).Name
End Function
Option Compare Database
Option Explicit
Private Sub Command0_Click()
MsgBox DBtest(CurrentDb)
End Sub