Index Called PrimaryKey
Mar 6, 2006
Hi,
To make a long and tedious story short:
Does anyone know why Access (2003) creates an index called PrimaryKey and an index called User_ID when I'm in the table design view and ask it to make the User_ID field the primary key?
After years of database development I've only just noticed this. Not normally not a problem but for this:
Use ADOX to find the field name of the primay key for a table. I took the code right out of a Access 2000 developers handbook. It creates a collection of the table indexes and steps through them one at a time checking if the PrimaryKey property is true. It hits the index called PrimaryKey and says 'yes it's true, this is the PK', I then go on to use the index.name property in an SQL Select to create an ADO recordset. The only thing is that the index called PrimaryKey is not a field name and the field name User_ID is not a PK :eek:
I go into the indexes list in table design and delete and re-create the indexes and PKs as I want and the code works fine.
So, again, why does Access do this? I'm so confused! :confused:
View Replies
ADVERTISEMENT
May 9, 2007
Hello
I am trying to figure out how to make my database check to see if the primary key value is a duplicate of anything ive entered previously and if yes, for my database to bring up that record instead of adding a new record.
I know how to do bring up records using a separate combobox (find) but I cant seem to do it using the primary key field itself.
Many thanks in advance.
View 1 Replies
View Related
Oct 24, 2006
Okay,
I have 33,099 records in a query, that i'm importing into a table. (don't bother witht he semantics, it's from a linked dbf file)
The table does not have a primary key. Given Three Fields (out of 74):
Item_ID
Title
AltTitle
With the table populated with all the records, I highlighted those three fields in Design View of the table, and told told access to make all three of them the Primary key. Upon attempting to save the table, I got an error message saying that data in the table violated the primary key unique fields rule or what not.
So I wanted to make a query to determine where the error occurred. I could not off the top of my head figure out how to select only the duplicated records in a table, so instead, i figured if they violated the Primary Key unique field rule, there should be duplicate entries. so I did this:
select distinctrow item_id, title, alttitle from tbl_Table;
I got 33, 099 records returned on the DISTINCTROW. Strange as that was, I deleted all the records from the table, set the primary key as I wanted it, and then repopulated the table via my sql insert into commands. This time the table reports only 33,093 records, meaning 6 records somehow violate the primary key unique index, but don't violate a DISTINCTROW call. How can i find them to determine how they are violating the primary key unique index?
thanks
Jaeden "Sifo Dyas" al'Raec Ruiner
View 3 Replies
View Related
Mar 25, 2008
hey again, i usually don't post this much and prefer to work it out alone but i have no idea why this isnt working (and the error im getting)
below are screen shots, i am trying to make an improved booking system, but i don't know why its saying i have a null value (i went through and made sure all fields are filled, in all related tables just to make sure)
http://i71.photobucket.com/albums/i136/King-b-/QueryPrimarykey.jpg
http://i71.photobucket.com/albums/i136/King-b-/QueryPrimarykeydesign.jpg
Is your BookingID set to autonumber? If it is an autonumber, where does the B come from?
no i have them all set as text with a inputmask of B000 (so booking numbers have to start with a letter (b) followed by three numbers)
(i edited and made new post as had a vague, uninteresting title)
View 14 Replies
View Related
Mar 2, 2006
I am in a form that someone else created. It has 3 tabs to the form. It is almost like Excel, but the tabs are at the top, as opposed to the bottom. Are they called tabs, pages, or subforms or something else? I can't figure out how to add one to a different form I have created.
View 2 Replies
View Related
Feb 6, 2007
What I want to do, is have an unbound form, user enters data in to it, then clicks on a 'save' button which then writes the data to a new record within a table
I have got no idea what it is called so find it hard to do the search.
View 14 Replies
View Related
Jul 22, 2005
A stupid question here...
I have a form that has a single bound text box that is set to currency. The table is also set as currency with decimal places set at 2. I have my own save button
Now I want to catch if the user types in text instead of numers and display a suitable error message.
When the user presses the save button I call this code:
DoCmd.RunCommand acCmdSaveRecord
heres the before update event
Private Sub Form_BeforeUpdate(Cancel As Integer)
On Error GoTo errHandle
If Not IsNumeric(hourlyRate) Then
MsgBox "Please enter a number for the hourly rate", vbInformation
hourlyRate.SetFocus
Cancel = True
Else
If (hourlyRate < 0) Then
MsgBox "Please enter a positive hourly rate", vbInformation
hourlyRate.SetFocus
Cancel = True
End If
End If
Exit Sub
errHandle:
MsgBox Err.Description & " " & Err.Number
Resume Next
End Sub
However the update event isnt called and I get an access message saying that the value you entered isnt correct for the field blah blah blah.
Q - How do I stop this access message from being shown???
btw - If I enter in a negative number my message box is shown, and then i get another access message saying that the run command was cancelled.
arghhh - I dont want these :-)
View 4 Replies
View Related
Sep 15, 2006
I've got a mental blank, I want one of those things that is a text box with little up and down arrows on the right so you can choose a number. What's it called?
View 9 Replies
View Related
Jan 5, 2008
In Access 2000, I am using a form with fields for TimeStarted and TimeFinished. After the user has filled in the TimeStarted, the After_Update event sets TimeFinished to one hour after that. I would like to use what I think are called "Spinners" so that the user could simply click on increment or decrement buttons to change the FinishTime.
I'm not sure about the name of the feature, so it is hard to find help to get started. Would appreciate any guidance. Thanks, Andrew Thorpe
View 5 Replies
View Related
Dec 12, 2007
Hi, I have a strange issue. Every now and then, when i start up my database (still in development) it either asks me for a value thats used in a sql command, or faults with an error saying it cant reference a value. The stragne thing is that the values that get pinged are not set until im a few forms into my database, and shouldn't even be thought about by the database yet. Is there something im missing here?
An example,
It asks for a change reference number on login form load, however that value isn't called until a button is pressed on the menu form which loads the change form. That same button sets the change number
View 1 Replies
View Related
Aug 27, 2015
Is the calling Form name or the event handler's sub name available in called module? I need it in order to determine the form's name as in [Forms]!someformname!some control.
View 7 Replies
View Related
Aug 11, 2011
Is there an easy way to propogate a value from one form to another?
I have two forms: Form A and Form B
Form A is the main: it contains many field including a Supplier CB.
Form B allows the user to add a new supplier if it is not on the list..
Form A allow user to pick a list from the table of suppliers. I allowed edit ietm list in the properties to add the list of suppliers to grow as new supplier are entered. I pointed the user to Form B ton enter the new supplier.
Things going well as I planed, however it is annoying when I enter the new supplier in Form A and respond "yes" to add new items I have to retype the new supplier in Form B again. I have about 11 fields in Form A that will follow this theme. This will not be user friendly if not fixed.
View 4 Replies
View Related
Oct 19, 2005
:eek: :eek: :eek: :eek: :eek: :confused: :confused: :confused:
I am trying to update a database table via a command button on the main form, that uses tabbed sub forms.
The database gets its data from paradox data tables copied our company's
third-party software. These table files are copied from one location to another to stop the paradox database from locking up and giving me errors during the import process of this database. I then link to these files at a pre-determined location on a local computer hard drive.
When I try to run the code below I get the error about the table being
locked by a user or process. As you can see I have tried adding a pause
incase the files are still being copied but this does not seem to be the
problem.
I have used a msg box to confirm that the copying process has completed before starting the make query, but the same error comes up after I click ok.
Can anyone suggest anything else.
As you can see from the simplicity of the code below I am a beginner so take it easy on me, by not taking knowledge for granted. :)
code:
------------------------------------------------------------
Dim response
Dim stDocName As String
Dim stLinkCriteria As String
response = MsgBox("Are you sure that you want to update xxx with Customer
data from xxx?", vbYesNo, "Perform Update")
If response = vbYes Then
‘pause software to let any pending work to be completed
Sleep (5000)
‘close active form
DoCmd.Close
‘close all active forms
Do While Forms.Count > 0
DoCmd.Close acForm, Forms(0).Name
Loop
‘pause software to let any pending work to be completed
Sleep (30000)
‘delete existing file
Kill "c:folderfile DATA.DB"
‘replace with new file
FileCopy "J:Folderew_DATA.DB", " c:folderfile DATA.DB "
‘pause software to let any pending work to be completed
Sleep (40000)
DoCmd.SetWarnings False
stDocName = "Make_DATA"
DoCmd.OpenQuery stDocName, acNormal, acEdit
‘pause software to let any pending work to be completed
Sleep (35000)
stDocName = "Make_DATA_SUMMARY"
DoCmd.OpenQuery stDocName, acNormal, acEdit
‘pause software to let any pending work to be completed
Sleep (35000)
stDocName = "qry_Update_ Status"
DoCmd.OpenQuery stDocName, acNormal, acEdit
‘pause software to let any pending work to be completed
Sleep (35000)
‘open up main form when finsihed
stDocName = "main-form"
DoCmd.OpenForm stDocName, , , stLinkCriteria
DoCmd.SetWarnings True
Else
End If
View 3 Replies
View Related
Sep 8, 2013
This module is giving me the "undefined function" error message when I try to run my query. I don't know why, but I have checked that there are no references with "missing" and there are not. I also added the word "Public" to the function becasue that was advised by another forum user. I thought it worked perfectly the first time I ran this query, but now it is not working and I do not recall making any changes. I have called the module basFunctions:
Option Compare Database
'************************************************* *********
'Declarations section of the module
'************************************************* *********
Option Explicit
'================================================= =========
' The DateAddW() function provides a workday substitute
' for DateAdd("w", number, date). This function performs
' error checking and ignores fractional Interval values.
'================================================= =========
Public Function DateAddW(ByVal TheDate, ByVal Interval)
Dim Weeks As Long, OddDays As Long, Temp As String
[code].....
View 3 Replies
View Related
Sep 30, 2013
I'm using shellexecute in my form whenever a picture is clicked the respective program/ application will open to show the picture. Because I want to see the picture more clearly by zooming it in or out. But the problem is I don't know how to disable the delete button and prev./next button, because I want the user use the program only to zoom it in.
View 4 Replies
View Related
Oct 16, 2014
I know its not possible. But Just wanted to confirm. Not at all possible?
Code:
Function PreImport(BookToImport As Workbook)
For Each cell In BookToImport.Sheets(1).Rows(1).Cells
cell.Value = Trim(cell.Value)
Next cell
BookToImport.Sheets(1).UsedRange.Rows(1).Replace ".", "_"
End Function
View 1 Replies
View Related
Jul 10, 2014
I have a continuous form... and I want to filter the table in the background using the text box called "Badge" (boxed in red in my picture.) You can see the corresponding part over in the filter field. When I display the form, though, Access still asks me for the Badge value, so it's not linking. What formatting am I missing to properly refer to the field?
View 5 Replies
View Related
Jan 8, 2013
I am making my very first tentative steps to convert my most complex Access 2003 app to run under Access 2007. There are no obvious problems when simply opening my original MDB file in Access 2007 or running it after conversion to an ACCDB file. However, when I try to run the ACCDB file under the Access 2007 Runtime I get a "You can't carry out this action at the present time..." error. This is then followed by the "Execution of this application has stopped due to a runtime error..."
To be more specific, I only get that error when I deliberately hide the back end database and thus invoke code triggered via Autoexec to allow the user to browse for the missing database. This code works fine when running under normal Access 2007 so it appears to be a Runtime issue.
View 3 Replies
View Related
Nov 18, 2013
I am struggling trying to execute a function inside a Form_current event to display some stats.
The Function is this:
Code:
Function FlightsByAircraft(Aircraft As Long) As Long
Dim rst As DAO.Recordset
Dim dbs As DAO.Database
Dim str As String
str = "SELECT * FROM tblFlights WHERE AircraftID = " & Aircraft
[Code] ....
The code for the Form_Current event is this:
Private Sub Form_Current()
txtStats1 = FlightsByAircraft(Me.AircraftID)
Very simple. Well, the problem is when I move to a new record, a error message comes up: "Run-time error '94' - Invalid use of Null". It is because the AircraftID is not populated at that time. I tried to insert in the function code something like that:
Code:
If IsNull(Aircraft) then
exit function
else
.... (the DAO.Recordset code)
but it doesn't work.
View 8 Replies
View Related
Nov 16, 2013
And then called this join as a symbol or variable, and then have it use to select the items from these joined tables, can this be done in Access? Here is an example of a code that I created, but it has an error message saying the FROM syntax is incorrect.
Code:
SELECT firstJOIN.trainID, firstJOIN.trainName, firstJOIN.stationID, firstJOIN.stationName, firstJOIN.distance_miles, firstJOIN.time_mins
FROM (trains INNER JOIN ((station INNER JOIN lineStation ON station.stationID = lineStation.stationID)
INNER JOIN bookingLeg ON bookingLeg.startID = station.stationID or bookingLeg.endID = station.stationID )
ON trains.trainID = bookingLeg.tid) as firstJOIN
Can Access do something similar to this, in the FROM statement I joined 4 tables, because each unique fields are in each table and I have to joined them to get those fields. I called this join firstJOIN and in the SELECT statement, I list those columns in the table by calling it firstJOIN.trainID. Can Access do something like this, but syntax it differently?
View 6 Replies
View Related
May 15, 2006
hi
when creating indexes for databases what needs to be indexed? is there an article online that explains it??
View 5 Replies
View Related
Apr 21, 2006
i
i do a sum on a field..... if i put an index on this field
does query will be faster?
thank
View 1 Replies
View Related
Aug 23, 2005
I created a help file for a using a db I created, though I am thinking it would be nice to have it "look more professional" something similar to the Contexts and Index help option found in IE.
I am think a form would be the easiest to do with a subform for each element in the contents, so when the user clicks on an element on left form (which is the contents) the detail of that page appears in the right form the subform (perhaps just using the visible property)
There are tab options for a form so I can use that to make the contents, Index, search, favorites
some questions come to mind though...
0) how would I create collapsible menu (like a tree menu) see the contexts and Index help option found in IE.
1) how to create a search field to look for anything in the db except the code (i.e. part of a record, a description of the record, etc.) ?
2) how would I create a favorites section (a place to save help topics viewed) ?
3) how do i create a navigation system (back and forward through the subforms) - it seems I would need to track which forms are displayed and when then use that to navigate back and forward ?
4) how create various options such as stop or refresh search queries, and perhaps turning on/off select highlight
Finally is there something similar to this already out there that I can just customize various options off of, perhaps even a tutorial.
thanks for any direction you might be able to provide.
View 2 Replies
View Related
May 16, 2005
I have several forms that can be called from more than one other form, but I need to build my forms so that the user is returned to the form from which they started.
I have looked in the help files and FAQ and I can't find what I am looking for.
Please, can someone direct met to the required information or tell me how to achieve this?
Thanks,
Kev.
View 1 Replies
View Related
Nov 23, 2005
I have ID field data type is auto number
I need to initilize it to zero after deleting all the records.....
tell me a way to do this
View 1 Replies
View Related
Jan 21, 2007
I have 2 fealds ( Id and date ) they are primery keys in the table , I want to prevent duplacte id to the same date . ( MSGBOX after update the date )
View 7 Replies
View Related