I have a form under development that is to assign an invoice number to a specific set of records based on the client, contractor and job type.
All the above are combo boxes and the first 2 have rowsource directly from tables, no problem.
The 3rd, JobType is dependent on the first 2 being identified first. Thus the query builds from information on the loaded form.
I have built a query that obtains the data needed for the combo-box whose SQL is as follows:
SELECT [Lookup:Job_Description].Job
FROM (([Lookup:Clients] INNER JOIN [Lookup:Contractor] ON [Lookup:Clients].Client_ID = [Lookup:Contractor].Client_ID) INNER JOIN Contractor_Fees ON ([Lookup:Contractor].Contractor_ID = Contractor_Fees.ContractorID) AND ([Lookup:Contractor].Client_ID = Contractor_Fees.Client_ID)) INNER JOIN [Lookup:Job_Description] ON Contractor_Fees.Job_Type = [Lookup:Job_Description].Job_Key
WHERE ((([Lookup:Clients].Company_Name)=[Forms]![frmAssign_Invoice_Num]![cboCompanyName]) AND (([Lookup:Contractor].Contractor_Name)=[Forms]![frmAssign_Invoice_Num]![cboContractorName]));
--- hope you can read that!
I have attempted to format this so that it can be executed in code under the GotFocus event. My code, which does compile looks like this:
Dim dbtmp As DAO.Database Dim tblObj As DAO.TableDef Dim rs As DAO.Recordset Set dbtmp = OpenDatabase("C:WINDOWSBureaudevcli.xls", False, True, "Excel 8.0;") DoEvents Set rs = dbtmp.OpenRecordset("select * from [DEVCLI$A1:C10]")
in the last line i would like replace DEVCLI (the Excel sheet name) by a variable to make my program works with any excel file. What is the syntaxe for that ? Thanks in advance for help. VINCENT
Hi, I wud like to know why this syntax is not working. select * from table_name where col_val like 'a%'
This returns the column values that start with 'a'. I was getting the result properly few days ago. But now suddenly this query doesnot give the result. When i tried this out in a website it was working there, but not in access.
Can anybody see what is wrong in this syntax? If the syntax is right where wud be the fault?
Can someone tell me how to insert the contents of a variable into a table? I am trying to add selected items from a listbox (Members) into a temporary table (tempMembers). The code is below. On debugging, it picks up the contents of the variable (iMemberID) OK, but adds "0" to the temp table (both are integers). I'm pretty sure the problem is in the Insert statement below (stSQL3), but I can't figure out how to write it!
Any help would be greatly appreciated! Thanks
stSQL3 = "INSERT INTO tempMembers (MemberID) VALUES & iMemberID & ;" For Each varItm In Me!Members.ItemsSelected iMemberID = ctl.ItemData(varItm) DoCmd.RunSQL stSQL3 Next varItm
Can someone help me on the syntax for the following? I have two tables: one is TapeNumber and has one field (Tape_No) autonumbered PK. The other table has information about the video and uses the Tape_No as a secondary key.
I have a form to add information about videos. I have the form bound to the first table, so it adds a new TapeNumber when I add a record. I have a subform displaying the video information for that tape (there may be several videos recorded on one tape).
When I add a new tape (or video to an existing tape), how do I save the tape number to the second table?
have this code which keeps on giving me this error...I dont know whats wrong with the code please help tried removing the quotes (rstStudents.Open "SELECT * FROM Students WHERE Regno = " & _ txtReg , _ CurrentProject.Connection, _ adOpenStatic, adLockReadOnly, adCmdText) but then it wont retain any records even if they exist in the table
here is the original code
rstStudents.Open "SELECT * FROM Students WHERE Regno = '" & _ txtReg & "'", _ CurrentProject.Connection, _ adOpenStatic, adLockReadOnly, adCmdText
ERROR MESSAGE>>>>>>> Runtime Error '-2147217913 (80040e07) Data type mismatch in criteria expression
the code is supposed to use number input by user to search in a table and fill all the other fields in the form with the table data (it is run on lost focus of the text box were value has been input)
the whole code :::::
Private Sub txtReg_LostFocus() Dim rstStudents As ADODB.Recordset Dim blnFound As Boolean Dim fldItem As ADODB.Field
blnFound = False
If Me.txtReg = "" Then Exit Sub
Set rstStudents = New ADODB.Recordset rstStudents.Open "SELECT * FROM Students WHERE Regno = '" & _ txtReg & "'", _ CurrentProject.Connection, _ adOpenStatic, adLockReadOnly, adCmdText
With rstStudents While Not .EOF For Each fldItem In .Fields If fldItem.Name = "Regno" Then If fldItem.Value = txtReg Then Me.txtName = .Fields("Name") Me.txtAdd = .Fields("Address") Me.txttel = .Fields("Telno") Me.txtTutor = .Fields("TutorName") Me.txtbks = .Fields("NoBooksonloan") blnFound = True End If End If Next
.MoveNext Wend End With
If blnFound = False Then
MsgBox "No student record to display" ' ... and reset the form ' cmdReset_Click End If
I am trying to open a PDF from Access. I get it to work but it requires me to hard code the path and fiel name....
The path will always be the same although the file name will change. RIght now I get the fiel name from a textbox on a form...I am trying to change the below working code with a varaible instead of the path....I think there is some systax issues that I cannto fingure out
TotPath is the variable that holds the entire path to the file "X:Map_LibraryPark_and_Rec_AsbuiltPRA_19_73-01_W0.pdf"
This variable is rebuilt everytime the user selects something on the form....so the actual File name will change every time...
Does anyone have and ideas as to how to incorporate a variable instead of the hard coded path?
THank you all for your help.....
Code:WORKING CODE: 'Shell "C:Program FilesAdobeAcrobat 7.0AcrobatAcrobat.exe X:Map_LibraryPark_and_Rec_AsbuiltPRA_19_73-01_W0.pdf", vbMaximizedFocus ' open a txt documentNOT WORKING CODE:Shell "C:Program FilesAdobeAcrobat 7.0AcrobatAcrobat.exe TotPath", vbMaximizedFocus ' open a txt document
I'm familiar with SQL but not with Access97 - some wierd syntax here!
I'm creating a Query that is to Delete records from a table depending on a non-key field in a second table.
I first tried an INNER JOIN
DELETE Activity_Preferences.* FROM Activity_Preferences INNER JOIN Activity_Key Activity_Preferences.Activity_Key=Activity_Key.Act ivity_Key AND Activity_Key.Complete=1;
which was initially accepted but then complained about the INNER JOIN after I went in a second time to 'fix' the error.
I've finally got the following syntax accepted:-
DELETE Activity_Preferences.* FROM Activity_Preferences, Activity_Key WHERE Activity_Preferences.Activity_Key=Activity_Key.Act ivity_Key AND Activity_Key.Complete=1;
But when executed still gets the following error (same as for the INNER JOIN):-
Hi, In a form i use the following filter fonction : DoCmd.ApplyFilter , "CliNom = '" & RunCli & "'" The problem is that sometimes RunCli (wich is a name) contains ' symbol and then generates a syntaxe error, is there a way to prevent that ? Thanks in advance. VINCENT
On my form I have 2 radio buttons rdoAll and rdoSpecific. If rdoAll is true then it prints a report. THis part works fine. However if rdoSpecific is true then I make visable combo box to look up an ID. Then when I click the button I want the same form to open but with just the info pertaining to the ID selected. Here is my code:
Private Sub cmdLotHistory_Click()
Dim stDocName As String, stSelection As String
stDocName = "rptLotHistory"
If Me.rdoAll = True Then DoCmd.OpenReport "rptLotHistory", acViewPreview End If
If Me.cboLotLU.Value > 0 Then stSelection = "[LotID] =" & Me![cboLotLU] End If
I am using the folling code in a after update combobox event:
Dim rst As DAO.Recordset Dim sqlwhere As String
sqlwhere = " "
If IsNull(Me.comboSearchSerial) = False Then sqlwhere = "SerialNumber='" & Me.comboSearchSerial & "' and " End If
mysql = "SELECT TBL_RMA.* from [TBL_RMA] Where " mysql = mysql & sqlwhere mysql = mysql & ";" Forms!FRM_RMA.RecordSource = mysql
Exit_comboSearchSerial_AfterUpdate:
This is currently working for me with SerialNumber being a text field. I would like to use the same code substituting SerialNumber with a Date field. I know its probly an issue with the use of quotes, but I can't seem to figure it out. Also, if I wanted to use a number format, what would I use... Thanks Gregg
I have a FE/BE access database. I have split it for our business processes from the original owners who decided to keep it combined. I have in my code Set rst = CurrentDb which needs to point to the BE (where the tables are) and I am struggling with getting the proper syntax. My error msgs are as follows:
"Operation is not supported for this type of object" (most likely becuase the rst is nothing)
I then get an error msg related to the form that it cannot update the StudentID field.
The help VB help module is not able to display this information..
I am trying to run the query below to tell me how much stock a company has available by deducting the amount dispatched from its allocation. I am getting an error message;
Run Time error '3061' Too few parameters expect 2
The code is;
Dim db As DAO.Database, qr1 As DAO.QueryDefs Dim rs1 As DAO.Recordset, rs2 As DAO.Recordset Dim varVal0 As Variant, varVal1 As Variant, varVal2 As Variant Dim strSQL As String Set db = DBEngine(0)(0)
VarVal0 = Me.WINENUMBER
strSQL = "SELECT Sum(tbl_Data_DispatchLineitems.Amount) AS Amount " strSQL = strSQL & "FROM tbl_data_DispatchDetails INNER JOIN tbl_Data_DispatchLineitems ON tbl_data_DispatchDetails.DispatchID = tbl_Data_DispatchLineitems.DispatchID " strSQL = strSQL & "GROUP BY tbl_data_DispatchDetails.TradingName, tbl_Data_DispatchLineitems.WineNumber " strSQL = strSQL & "HAVING ((tbl_data_DispatchDetails.TradingName)=[Forms]![frm_data_Orders]![TradingName]) AND (tbl_Data_DispatchLineitems.WineNumber = VarVal0)"
Set rs2 = db.OpenRecordset(strSQL) rs2.Edit varVal1 = rs2![Amount] rs2.Close
I assume the error lies in the final line of the query code. Any help to find the error would be appreciated.
I have a function that builds a filter and it get a syntex error. It has three components and I must be missing something in combining them into the filter. SpecID and ReviewID are numbers. Selected is a checkbox and 'Yes' is a string. Can anyone see the source of the Syntax Error?
Private Function PlanFilter() Dim strFilter1 As String, strFilter2 As String, strFilter3 As String strFilter1 = "[SpecID] = " & [Forms]![frmMainEntry]![SpecID] strFilter2 = "[ReviewID] = " & [Forms]![frmMainEntry].Form!fctlReviewRequests!ReviewID strFilter3 = "[Selected] = 'Yes'" gstrFilter = strFilter1 & " And " & strFilter2 & " And " & strFilter3 & ";" Debug.Print gstrFilter End Function
Having problem with this parameter query which works off of a form and don't know how to resolve. Error being:- "Run-Time error 2342...A RunSQL action requires an argument consisting of an SQL statement."
Dim mysql mysql = "SELECT tbl_pallet_log.ID, tbl_pallet_log.Entry_Date, tbl_pallet_log.order_Number, tbl_pallet_log.Customer_No, tbl_pallet_log.Customer, tbl_pallet_log.Postcode, tbl_pallet_log.Pallets " & _ "FROM tbl_pallet_log " & _ "GROUP BY tbl_pallet_log.ID, tbl_pallet_log.Entry_Date, tbl_pallet_log.order_Number, tbl_pallet_log.Customer_No, tbl_pallet_log.Customer, tbl_pallet_log.Postcode, tbl_pallet_log.Pallets " & _ "HAVING (((tbl_pallet_log.Entry_Date) Between [Forms]![frm_customer_pallet_report]![txt_date_from] And [Forms]![frm_customer_pallet_report]![txt_date_to]));" DoCmd.RunSQL mysql
I'm not sure this can be done,but here goes it, I have 5 [plants] A, B, C, D & E. If one plant recieved [A] plant reject [Reject] then I need a response from plants B, C, D & E. If plant [B] receives a reject then I need a response from plant A, C, D and E. How would I show what other plants havent' responded>
How would I create a query for this? any idea's would be greatly appreciated
I keep on getting a syntax error on the first [MU_ID]. Can anyone tell me what am I doing wrong please? You can e-mail me at Frank.Cappas@CIGNA.Com
Site: IF [MU_ID] BETWEEN ((SELECT [MU_Start] FROM [Sites] WHERE [Site] = “BRB”) AND (SELECT [MU_End] FROM [Sites] WHERE [Site] = “BRB”), “BRB”, {IF [MU_ID] BETWEEN ((SELECT [MU_Start] FROM [Sites] WHERE [Site] = “BRI”) AND (SELECT [MU_End] FROM [Sites] WHERE [Site] = “BRI”},"BRI")
I'm trying to get my head round this query and not having much luck.
I have table that contains. amongst others, two fields I need to use - Date and Amount. I already have a query that returns me the number of entries for a given month, along with the total value.
SELECT Count(*) AS [Number of Entries], Sum(NBReferral.[Amount]) AS [Total Amount], NBReferral.Date FROM NBReferral GROUP BY NBReferral.Date;
What I want is to also provide a running total (year to date). Using this:
SELECT Count(*) AS [YTD Number of Entries], Sum(NBReferral.[Amtount]) AS [YTD Total Amount] FROM NBReferral;
Combing the two queries works as long as there is only one month. Unfortunately, I'd like to see each month's YTD figure displayed as shown
Date Number of Entries Total Amount YTD Number of Entries YTD Total Amount Nov 2006 5 10000 5 10000 Dec 2006 3 5000 8 15000 Jan 2007 6 12000 14 27000 etc.
What I currently get, as you would expect, are the same YTD totals applied to each month:
Date Number of Entries Total Amount YTD Number of Entries YTD Total Amount Nov 2006 5 10000 14 27000 Dec 2006 3 5000 14 27000 Jan 2007 6 12000 14 27000 etc.
Probably a fairly straight-forward query for someone with a bit more experience. Any ideas?
I'm running a VBA query in excel trying to import the field from a table, simple so I thought, any idea on why i'm getting syntax error codes on this part?