Modules & VBA :: Updating All SQL Stored Within All Forms
Mar 4, 2014
How would I update all SQL stored within all forms to change its syntax?I am returning all the row-sources for all the comboboxes on all forms in an Access db. Most work fine but some have syntax errors, for example double quotes instead of single. Is there any way of finding these stored SQL statements and updating them on mass, as I am doing it manually at the moment!
I'm having an issue getting a return value from a stored procedure that I'm calling from VBA. This is what I have at the moment:
Code: Dim strDate As String Dim strWOStatus As String Dim CurrentConnection As ADODB.Connection Dim adoCMD As ADODB.Command Dim adoRS As ADODB.Recordset Dim ParamReturn As ADODB.Parameter
[Code] .....
The problem I am having is this error: Error: 424 Description: Object Required
The line of code it errors on is:
Code: Set .Parameters("@PartsUSedMTD").Value = ParamReturn
And the value of ParamReturn is always Null after it hits the line before it.
So it seems like it's not really creating the parameter variable SQL Server needs to run
I defined a public variable and then for being able to filter a query results, assigned it to a public function. The problem is that function doesn't get the variable's value.
I have code for calling stored procedure with parameters,which is as follows
Dim qdf As DAO.QueryDef, rst As DAO.Recordset Dim IdValueToProcess As Long
IdValueToProcess = 221177 ' test data Debug.Print (IdValueToProcess) Set qdf = CurrentDb.CreateQueryDef("")
[Code] ....
And my stored procedure is
Code: ALTER PROCEDURE [dbo].[spItemDesc] @ItemNo varchar(200) , AS BEGIN set nocount on ; select ProductDesc1,ProductDesc2 from ProductDatabase.dbo.tblProductInfo where ProductNumber = @ItemNo END
Following concerns about someone accidentally deleting the access database we have been using to crunch performance numbers, I have successfully moved the data on to an SQL server
While the database works as it is, several of the queries are running extremely slow. I therefore decided to see if a stored procedure could run the number crunching on the server instead of passing the data back and forth all the time.
I have taken the series of queries and converted them into a stored procedure that runs too fast for me to blink while giving the same results as before.
The problem I face is that I can trigger the stored procedure from the server management studio manually while supplying the variables needed thus providing the data I need to export to excel in a table for this purpose.
What I want to do is to have a form in access supply the chosen variables (like I could before) and run the stored procedure at the click of a button as part of a series of other queries.
I have looked at pass-through queries but apparently they do not take kindly to variables unless they are hardcoded. The other solution would be to trigger it from VBA but I have not been able to find a solution I could get to work.
How to run a stored procedure on an SQL server from access while also giving it the variables it needs?
Stored procedure name: spNearMissCalculation Variables: @SelectedDate (date format) (taken from a form field) @SelectedVessel (nvarchar(max) format) (taken from a form field) @SelectedVesselGroup (nvarchar(max) format) (taken from a form field)
I have two different database files. One is 2010 ".accdb" format where I have created a form and the inputs to the form is getting saved as records to an access.mdb file in a shared path.Now if the users want to edit the existing record I should allow them to search their previously submitted record with a unique ID number.
I know it is possible when we have both the form and table in the same db. But I want to know whether it is possible to search with a unique ID and pull the data from different db in a shared path using a command button?
I have a form that has combo boxes and text fields (as well as sub forms). There is also a button linked to some code that says'
Private Sub cmdQuote_Click() 'Creates quote date and prints quote Me.QuoteDate = Now() Me.cbAgentID.Requery DoCmd.OpenReport "Quote", acViewPreview, , "BookingID = " & Me.BookingID End Sub
When the button is pressed the QuoteDate field (it is bound) should be be populated, but unfortunately it is not. I have played with refresh and requery but cannot derive a solution.
I'm trying to search a for string within a subform to find information stored on the mainform to which the particular subform belongs.
The problem is that the subform is generated from a query which uses a number from the main form to generate.
So the subform record is only generated when the correct mainform record associated with it is loaded.
Now to solve my problem I've made a new query that brings up ALL the results that could be generated by the main form and from that I can search to find my search term I'm after and read off the ID number to tie it back to the mainform.
But all of this is done manually, I want a way to do all this using VBA in a way that the user can't edit any records as they are doing it.
I have several text boxes which I can populate using the DLookup.I have images I want to display for individual records.I use a search (textbox) to input client name and this populates all other textboxes. I am trying to get the relevant image to display also using this search box. I have also disabled record selectors just tidy up the form. I have tried coding the image control on the AfterUpdate event of the search box. Full path to images are stored as JPG in my ClientTable not as OLE.
I chose the criteria 2 for the filter just as a test as I knew there are some records with that value in the master category field.
The problem is when ever i click the button to apply the filter it clears all the data as if it has not found any records with that value.
Is my syntax and method OK? Why its filtering everything out?
The only other thing to consider is that the field I am filtering on was set up using a lookup wizard linked to a table so the values stored are a foreign key (hence the value being 2 rather than something descriptive).
I would like to first state that I am new to Access and trying my best to pick up on skills, so pardon if my questions seemed redundant or illogical. I'm trying to create a sort of quick-access/all-in-one Access form that..
1) Displays contact details stored in an excel sheet 2) Opens application on click 3) etc..
I am able to get pointer 2 sorted out, however am having trouble with pointer 1.
I have the contact details stored in an excel sheet, of which I am aware of how to import it into Access. However, my idea was to have a tab where firstly there are 4 buttons, say buttonA to buttonD.
I want it to perform an action such that when i click buttonA, 5 other buttons (say button1 to button5) appear on the right of the 4 existing buttons.
If I press buttonB however, button6 to button10 will appear and replace the button1 to button5 at the same spot.
After which, if I press button1 etc, there will be a field where contact details are displayed (name/number/etc) and it switches as I press different buttons.
I have a VBA script that looks at a date on a form, adds a certain number of months (selected by the user). at the moment i can output the new data to a message box. I want to update a table with the new data value.
When I try to run a simple update query written in VBA I get no errors but the field that I am trying to update just gets a 0 instead of the appropriate ID that I am passing.
Code: Function ExtractProjects() On Error GoTo ErrHandler: Dim db As Database, rs As DAO.Recordset, rs2 As DAO.Recordset, var() As Variant, i As Long, qdf As DAO.QueryDef, ii As Long Set db = CurrentDb
[code]....
The funny thing is if I run the query itself it works by using a parameter query but when I try and run it like this all I get is 0's in the field that it's supposed to be updating.The field [(SDSK) Charges Master].PID properties are as followed and is a linked table:
Type: Integer Indexed: Yes (Duplicates Allowed)
A debug.print of the results of the query trying to be ran is the follows:
Code: UPDATE [(SDSK) Charges Master] SET [(SDSK) Charges Master].PID = 1 WHERE ((([(SDSK) Charges Master].[IBB Date]) Between #10/24/2014# And #11/19/2014#) AND (([(SDSK) Charges Master].[Charge Num]) Like '*BAA*' And ([(SDSK) Charges Master].[Charge Num]) Is Not Null));
As you can see it is providing a number to be set to but instead it just fills it in with a 0.
In my form I have the listFunctions list box set to Multi Select "Extended" in the following code contains a line to execute a query based on the selected items in a listbox. but for some reason instead of only changing the selected items it is changing all items in the listbox. I stepped through the code and it is looping the correct number of times based on the amount selected but is still changing all.
eg.if I select 3 items from the list, it loops through the execute 3 times.but the total 6 items will change.
Code:
Private Sub cmdEdit_Click() Dim varItm As Variant Dim sSQL As String Dim ssSQL As String
I have an excel spreadsheet that uses a data connection to a website to download text. I have the data connection properties to refresh upon opening the file. If i double click the file from windows, it updates. Although using the code below doesn't work. When i've added the code ObjXL.Save before closing it, it usually saves a file with no data and no cells. I'm eventually going to switch visible to false.
Private Sub btnDownLoadSettle_Click() Dim XLapp As New Excel.Application Dim ObjXL As Excel.Workbook Set ObjXL = XLapp.Workbooks.Open("C:...Settlements.xlsx") ObjXL.Application.Visible = True ObjXL.Windows(1).Visible = True Sleep (5000) ObjXL.Close XLapp.Quit End Sub
I have a list box populated with record ID's all of which need a date field updated. I have been succesful at using the list box to update single records, but am not sure how to transfer this idea to work with multiple records simultaneously.
The code i am using is:
Private Sub Command13_Click() Dim i As Integer Dim strSQL As String Dim sMessage As String Set db = CurrentDb() Dim sTitle As String For i = List10.ListCount - 1 To 0 Step -1
I am trying to edit an existing record in my database.It goes to the correct record to update but will not update if "RecordUpdate" is specified as auto numbered.If the "RecordUpdate" is just specified as a number in the query it is fine.
I have been asked to add features (and fields) to an existing database containing private medical data. The idea is to add features to the empty database, test it with fake data, purge the fake data and deliver it to the user in another state with a simple update button. The Access 2010 database is in one piece (No front/back end).
I am looking for the best/shortest VBA method to move a lot of preexisting field data from the old database to the new version. I think I have it mostly figured out; I have code for counting, reading and writing the table names, field names and field data.
However, because the data types vary within the tables and there will be new fields in the new versions tables, my only idea, so far, is to code through the data table-by-table and field-by-field, a lengthy process with a large footprint. Moving entire tables or complete records may not be effective. Any faster way to transfer all these tables field data?
In attached file i am updating the YU field in YABANCI_UYRUKLULAR table where CALISMA_IZIN_NO fields is matching from YU table. But there is a problem after update i see one of the record's YU field is 10 character, it must be 11 character as in the YU table.
Currently I have an issue where on of the fields in a userForm will not update. I have tracked down the problem to an update Event procedure
Code: Private Sub txtRate_Change() Me.txtSales = Me.txtRate * Me.txtPages Me.txtGST = Me.txtSales * 0.1 Me.txtTotal_Inv = Me.txtSales + Me.txtGST End Sub
The idea being, when you update the rate, the Sales/Revenue figure will update based on that rate. For a while this seemed to work fine. but recently , it just will not allow me to update the field txtRate, I cannot understand why. I have now replaced the _Change() event for a _LostFocus() event. but I am not sure that is as reliable, and I am still puzzled / worried as to why the _Change event will not work.I'm on Access 2013, win 7 , using a front end db connected to the back end using linked tables.
I have a sub form that adds and displays appointments related to an order. The form has two combo boxes, cboVenderTypeID and cboVenderID and a date picker. There is a 3rd combo box on the parent form called OrderNode. The contents the cboVenderID combo box are filtered by the selections made in cboVenderTypeID and VenderID comb boxes. This works fine and adds the appropriate appointment to tblAppoints. The problem is when I try to add an appointment with of a different type (different value in cboVenderTypeID) all the values in the existing appointments change to the latest value selected in cboVenderTypeID.
Private Sub cboVenderTypeID_AfterUpdate() Dim strSQL As String Dim db As DAO.Database Dim rs As DAO.Recordset If Me.cboVenderTypeID = 4 Then