I'm trying to display a choosen record from a table with a record id that is a TEXT data type. A variation of this same code works correctly in another form where the record source is a table with a record id that is a AUTONUMBER data type.
The below code (Access 2000) displays the first record in the table.
Private Sub cmdTypeCodeSearch_Click()
On Error Resume Next
Dim strtyTypeCodeID As String
strtyTypeCodeID = GettyTypeCodeID
'Just put this in to verify record id
MsgBox "You selected " & strtyTypeCodeID & " for your record key"
If Not IsNull(strtyTypeCodeID) Then
Me.RecordsetClone.FindFirst "[tyTypeCodeID] = " & strtyTypeCodeID
If Not Me.RecordsetClone.NoMatch Then
Me.Bookmark = Me.RecordsetClone.Bookmark
Else
MsgBox "Record Not Found"
End If
Me.Refresh
End If
I'm using a 5-tabbed form and have put it in my detail section. Within the on click event of one tab knob i would like to activate some knobs in the form header where the tab resides on.
I've coded everything properly but in one or other way access doesn't seem to communicate between the tabbed form within the details and the form header. Anybody an idea?
I have a process which runs lots of slow append queries, so I want to reassure the user of progress, by changing the font colour of labels to green when the relevant queries have finished. This is the code I'm using
Code: 'Update the older data if that option is selected If Me.Menu_YearOption.Value = 1 Then DoCmd.OpenQuery "2-10 Append FY1112" Me.lbl1112.ForeColor = 32768 Me.Repaint DoCmd.OpenQuery "2-12 Append FY1213"
[Code]...
Each query takes about a minute to run, as it gets data from a sharepoint server, but the labels don't turn green one at a time as expected. Instead, I get the spinning wheel until all the queries have run, then all the labels turn green together.
Is there something else I should be doing rather than Me.Repaint ?
I saved my front end db as .accde in order to distribute it without user being able to edit my objects. As it turned out, when I open the .accde now I see my code doesn't work anymore. I have a lot of startup code and now it doesn't trigger at startup. Basically all my forms use vba code and none of them works in .accde . Accdb version works without any issue.
In trying to respond to another thread, I have run into something that is confounding me (or maybe I'm just getting dense).
We have a subform. One field has an event on DblClick to launch a search form. When the user identifies the target, he/she clicks a button on the subform. This pushes the appropriate value into a field on the original subform using VBA code and closes the search form. This all works fine.
The behaviour that is driving me bugging is when the user clicks on a new record (i.e. new line) on the subform, we would like to automatically generate the next record (E.g. when you type in a field of a record with autonumber in datasheet mode, Access automatically generates the next record). Currently this doesn't happen - Access generates the PK for the record being modified, but doesn't generate the view of the next record.
What really confuses me is that I have created similar looking example in which this works just fine. I can't figure out which of the differences between the two samples is causing this behaving.
Also, typing information into the field on the subform does cause the next record to be generated. It is just doing this via code that works in one case but not another.
I have narrowed it down to the actual subform. Even as a standalone form the form exhibits the same behaviour.
For reference, the original thread is http://www.access-programmers.co.uk/forums/showthread.php?t=99457
I have lookup table I use to return names for various "Sales Class" codes.It all works good but if there is a code that isn't in the lookup table it leaves that field empty.I want it to return the word "Unknown" for any code that doesn't have a match.Here is the SQL:
Code:
SELECT [Data1].OrderNum, SalesClasses.[Name] FROM [Data1] LEFT JOIN SalesClasses ON [Data1].[Sales Class] = SalesClasses.[Code1];
In the Main Form , I have few buttons and I am writing the following code to open the right form when a button is clicked but unfortunately the code isn't doing anything. No form is opening. I am using MS office 2010.
Code: Private Sub BtnOption_Click() DoCmd.OpenForm "Form1", acNormal, , , acFormAdd, acDialog End Sub Private Sub Form_Load() 'Me!Label1.Caption = "Welcome " & Environ("username") & "!"
Works great, but when I hit the number "3", (3 times in row) it will let me into the form. I want it to not let me in IF I don't know the password.
Where did I go wrong?
Private Sub Form_Load() Dim pw As Variant
If InputBox("What is the password?", "Password") = "1" Then Else MsgBox "Invalid Password", vbCritical, "Sorry Charlie" DoCmd.Close If InputBox("What is the password?", "Password") = "2" Then Else MsgBox "Invalid Password", vbCritical, "Sorry Charlie" DoCmd.Close End If End If
I protect my code from people being able to read it by setting a password on the code from Tools > Properties, selecting the Protection tab and entering a password, and clicking "Lock Project"
Is there a way to write code that will remove that Lock Project check and check it back on?
I've looked through the Application.SetOption command and it doesn't seem to be one of the choices. It would be very helpful if someone knew how to do this.
i am trying to run an append query in SQL which appends a calculated value into another table 50 times incrementing the day by one day each time. When I run it it asks me for the parameter [NewDay] each time. It is obviuosly not picking up the variable.
Can anyone tell me why ?
Dim NewDate As Date Dim n As Integer
For n = 0 To 50
NewDate = Date + n
DoCmd.RunSQL "INSERT INTO InventoryEvolution ( SAP, Stock, [Date] ) SELECT UK_Product_Estimate_Live.[RE SAP Code], ((Sum([Estimate01])+Sum([Estimate02]))/50)*-1 AS Stock, NewDate From UK_Product_Estimate_Live GROUP BY UK_Product_Estimate_Live.[RE SAP Code] HAVING (((UK_Product_Estimate_Live.[RE SAP Code])=513450))"
Hi all, I get this error "You tried to execute a query that does not include the specified expression 'SITENAME' as part of an aggregate function."
The query is:
SELECT o1.name AS SITENAME, o1.vertical_loc/10000000 AS LAT, o1.horizontal_loc/10000000 AS LON, c.CELLGLID AS CELLID, 'traffic_total' AS Expr1, sum((MEBUSTCH_HR+MEBUSTCH_FR)*period_duration)/sum(period_duration) AS Traffic, 'traffic_hr' AS Expr2, sum(MEBUSTCH_HR*period_duration)/sum(period_duration) AS Traffic_HR FROM objects AS o1, objects AS o2, c_bts AS c, p_generic_cell AS p WHERE c.int_id = o2.int_id and o2.parent_int_id = o1.int_id and p.bts_int_id = o2.int_id GROUP BY SITENAME, LAT, LON, CELLID, Expr1, Expr2;
I know the problem is with the group by clause. In MySQL it just works using "group by p.bts_int_id. I learnt in access i have to include all non-aggregated fields in the group by clause, and that's what I've done!! WHY!!Please help me!!!
Set cmd = New ADODB.Command Set cmd.ActiveConnection = CurrentProject.Connection cmd.CommandType = adCmdText
cmd.CommandText = "SELECT par1 FROM tblparameters Where tblparameters.gcnf = 'XMLexp' AND ((tblparameters.ccnf) Like 'ExpTijd*')" Set rec = cmd.Execute()
Do While rec.EOF = False MsgBox rec("par1").Value rec.MoveNext Loop
I don't get any result back. If I changed it likt the following: tblparameters.ccnf = 'ExpTijd1' , in the query, I get one record back. So my conclusion the query is right but the Like doesn't work in these circumstances?
hi folks, I am designing an application for an assignment for college, all seems to be going ok except that I have to teach myself access from a book. When I update a record on a form and go to another page it works fine, but if I attempt the same action ( for example creating an appointment then moving to a new form to confirm they have arrived) a second time I am getting an error which tells me I can't save the record. I think it is to do with updating the recordset when the new form is opened. I have an update record button on the form (created by the wizard) but it wont update on the second attempt. Could someone please tell me the code to update a recordset on the formload procedure. Ive tried me.recordset.refresh and me.recordset.requery but I still can't solve the error. Please help I've got to hand this assignment in in 2 weeks. thanks in advance Chris
I have a table with approximately 700 records. This table consists of a location field. I want a user to be able to select a location from this table via a form. Listboxes and Combo Boxes hold 255 rows. Plus, what user would want to use one of those to search through to find the location they are looking for. Any body have any ideas on a better way to do this? They have to stick to the list, otherwise I would just have a text box for them to type in.
I have two table with the same key field. However, in one table it is a text field while the other is a number.
I created a query from the table with the numeric key and converted it to text using the str() function. When the query is run, the values appear, left justified as if they are text.
However, when I create another query using the first query and the other table, I get no records out even though there are matching key field values in both tables (there are no leading zero problems).
Hi! I'm relatively new to Access (2003) . I had to modify a shared network app so I copied it off and renamed it, made my mods and everything is fine. I then went to another app that connects to the original app to obtain data for display and synchronization, modified the call to open the new app including the new mdw. When it hits the new mdw, it can't open it because it says it's being used exclusively or the workgroup file is missing. It's not being used exclusively and it doesn't appear to be missing. The network path is correct. If I use the mdw from the original source app, it works fine. Please advise! :(
I'm sorry if my thread is in wrong section, cause I'm first time on this great forum :(! I hope you'll undrestand me ;)
My problem is with my database for my coffee bar, man who made database is still, and I don't have somebody to repair my database unfourtanetly :(
I formatted my C:, cause I installed new OS Windows XP PR SP2, and everything is deleted, but I save this .mdb file, but I don't have instalation CD for this program, cause man who installed me this database didn't give me instalation file :(!
And I saved this .mdb file, and now I try to run this POS.mdb,I can open "POS KASA" in english POS CASH, and I see articles - (ARTIKLI), and value of them it account values of them, just program doesn't count for me like before "sume" or "total" of EX. one count, for example coca cola 2.5 KM, fanta 2.5 KM = 5 KM, and now he doesn't count sume - total in program total is "UKUPNO", if somebody to know to repair this, or something another what is importing to work this database like before, please help me, database is on bosnian, if you need translating just ask me, cause I don't know to edit this file, and to have access to change words :(!
1'st colone in program interface (bosnian - english)
Sifarnici -something like codes
Artikli = Articles Ulazi = Inputs Storno racuna = storno count Pregled storno racuna = review storno count
2-nd colone in program interface
Dokumenti - Documents
POS kasa = POS cash register Dnevni promet = daily exchange Trenutni saldo kase = current saldo of cash register
3-rd colone in program interface Reports
Printanje prometa po broju = Printing exchange by number Printanje prometa od datuma do datuma = Printing exchange from date to date Printanje trenutnog prometa = Printing current exchange
IZLAZ = EXIT :)
Actually for me the most important is POS CASH REGISTER, cause it doesn't count total value of one count , total = ukupno doesn't work, sume doesn't work, and I can't give on my guests count, and I have problem with inspection cause I don't have counts :(, please help me and if you can repair this; IN ADVANCE TNX MUCH!
Greetings to all, from Sarajevo, Bosnia and Herzegowina!
I'm sorry really on my bad english, and I hope you'll understand me :(!
I want to execute a delete query on a table of account records. The query contains two tables linked on account number, one with a list of unique records, linked to the other with "many" records to be deleted. For each unique record from table A, I want the delete query to delete all records with a matching account number in table B. However, I get a message stating that I "could not delete from the specified table." Huh???
I can manually delete from table B, or I can get the query to work if I don't try using table A as the control table and instead specify literal criteria. I have tried all three join types but still no luck. Any ideas?
I have an access query that I run on a regular basis but that doesn't always sort. It sorts most of the time, but once in a while it won't, which makes it really annoying and impractical.
I'm using the following code to autofill the city and state on my form. I can't figure out how to capture if there is no matching record in the table. If there is no matching record, I will:
1) inform the user with a msgbox then if the user wants 2) open a form to add the record to the table
Dim rst As DAO.Recordset Dim db As DAO.Database
Set db = CurrentDb Set rst = db.OpenRecordset("tblZipcodes", dbOpenTable)
rst.MoveLast rst.MoveFirst
Do Until rst.EOF
If strZipLookup = rst!ZipCode Then Me.txtCoCity = rst![ZipCity] Me.cboCoSt = rst![ZipState]
End If
rst.MoveNext
Loop
rst.Close End If
How can I capture if there is no matching record in the table?
Have a number of tick boxes on different forms. When the form is opened the tick box appears to be greyed out however it is enabled. Is there any way that these tick boxes can appear enabled???
I have a subform (based on table "Source") that allows the user to create a new record in another table "Events" (it copies some entries to facilitate entering new data). The data should then be dispayed in another subform. However, the newly created redord is does not show in the subform although I use Me.Refresh. When I close the form and then open it again it works - but there has to be an easier way.
How can I reload the data from the table. I have looked but am unable to find the right method.
The code:
'Create New Record in Table Events
Call AddEvent(EventDate, Country) 'This function opens the table and adds a record