I have a form in access database. On click of a button I want to perform update process for records in a table "abc" in the same database. I have written the following code in the onclick function,
Code: Dim rs As New ADODB.Recordset Dim rsCount As New ADODB.Recordset Dim CntVal As Integer Dim con As New ADODB.Connection con.Provider = "microsoft.jet.oledb.4.0" con.Mode = adModeShareExclusive con.Open ("C: est.mdb") rs.Open "Select * from abc" Do While Not rs.EOF rsCount.Open "select count(test) from abc where test = '" & rs.Fields("test") & "'" If Not rsCount.EOF Then CntVal = rsCount.Fields(0).Value Else CntVal = 0 End If rsCount.Close con.Execute "Update abc set testcount = '" & CntVal & "' where ID1 = '" & rs.Fields("ID1").value & "'" Loop
In the above code, I am not able to use the command,
con.Open (App.Path & " est.mdb"). It gives "Object Required Error". And while opening the con object I get the error "You attempted to open a database that is already opened exclusively by user 'Admin' on machine ''. Try again when the database is available."
I've got 2 sub forms that I intend on using via a toggle button from my primary form to access them. Is there anyone that can give me a heads up on creating vb code that when OnOpen it will automatically advance to a new record for data entry? I want the form to keep anyone from accidentally changing existing info in that regard. I'm still really new with VB.
I have a form that is created in Access but uses some VB code. Here is my problem..... I have one form that the users do money transactions on. Then I have created a form that will allow them to Void a transaction as well as Refund a transaction. On the Void/Refund forms it will query the user for the Receipt No. once that information is pulled in, there is a command button that says "Void Ticket Sale" on the Refund form it says "Refund Ticket Sale". What I'm trying to do is, once the user enters the receipt no and hit that Void/Refund Ticket Sale button - if it has already been voided/refunded, a message box will come up and say "This Ticket has already been voided/refunded". If it has not, the "Void Ticket Sale" command will carry on. Here is a snippet of my code, I'm not sure what I'm doing wrong.
Private Sub cmdRefund_Click() On Error GoTo Err_cmdRefund_Click 'this is a AddRec button, caption was changed to read Void
Dim Answer As Integer Dim Result Dim sqlstmt As String
sqlstmt = "Select Count( * ) from tbl_transactions where PaymentType = Void And VoidRefundID = Me.TransNumID"
Answer = sqlstmt
If Answer > 0 Then MsgBox "This Receipt No. has already been voided." Exit Sub Else
Result = MsgBox("Are you sure you want to Refund Receipt No " + Str$(Me.TransNumID) + "?", vbYesNo, "Refund Receipt")
If Result = VbMsgBoxResult.vbNo Then DoCmd.Close Exit Sub End If End If
I am using a database name as school. having a form name as form01.with cmd button close which close the form. I want to close form with ms Access database. So when user click close button application database will be closed.
I am able to export data to excel file, I would like to send the excel file created to the customer, is there a sample code I can use to do this in a module.
I have a 'tblStock' with fields 'ProductID', 'InitialStock', 'Buy', 'Sell' and 'UpdatedStock'. I also have a form 'StockUpdate' add values and also add new records to 'tblStock' .
If I have value [100] for IntialStock quantity, Buy [0] and sell [10], UpdatedStock will be [90] (that's done and fine!).
The problem is, I would like to make the UpdatedStock value [90] to be the NEW InitialStock, so that any BUY or SELL will keep updating the UpdatedStock and making it the NEW InitialStock for the next transactions and so on....
I've been using the following code successfully in Access 2003 & now I need to migrate to Access 2010. The purpose of the code is to use the items that the user selects in the list box to build the criteria of a query. Access 2010 keeps giving me a syntax error when I try to run the query & I don't know why:
My code is:
On Error GoTo Err_Command151_Click
' Declare variables Dim db As DAO.Database Dim qdf As DAO.QueryDef Dim varItem As Variant Dim strCriteria As String Dim strSQL As String
[Code] .....
The syntax error I get in Access 2010 is:
Syntax Error in query expression 'SELECT * FROM qryContractListSummarybyDateContract3TYPEBREAK WHERE qryContractListSummarybyDateContract3TYPEBREAK.Rep ortableName IN('Adbri Masonry NSW');'
Iam using the following code for inserting the values from access form in to the access database table ITEMS, but iam getting compile errors, may i know where iam going wrong in the code.
Also help me in updating, deleting and viewing of records from database table ITEMS to the form when i run the program.
Following is my code :
Private Sub ADD_Click()
On Error GoTo Err_ADD_Click
Dim cn As ADODB.Connection Dim rs As ADODB.Recordset
Set cn = CurrentProject.AccessConnection
'Create an instance of the ADO Recordset class, and 'set its properties
Set rs = New ADODB.Recordset With rs Set .ActiveConnection = cn .Source = "SELECT * FROM ITEMS" .LockType = adLockOptimistic .CursorType = adOpenKeyset .CursorLocation = adUseServer .Open End With
'Set the form's Recordset property to the ADO recordset
Hello to everyone!, Could I ask a help how could I possibly code MS Access Startup to set the MenuBar, ShortCut Menu, FormMenu, Special Keys to OFF to prevent user from using these keys when my application starts?
I dont get any errors with this code. Let me explain what im doing: T1 = temparary table (not really temparary but the values just change so often it might as well be) this table has field names: partname, order, maxorder, etc. stuff like that pretty much its a table that has records for each part name.
T2 = main database this table holds the order for all parts for a particular time and day
T1 is the one that people are familiar with, where as T2 's set up is something that they would not be, so for clarity we use T1 for displaying etc.
now my problem is, i try to transfer data from one table to another but it works sometimes and doesnt work others, i dont get any errors and i have option explicit on as well. if someone could look at this code and tell me if there are any problems that you see, the quicker the response the better.
technical specs: Access 2000 Windows 2000
Code: Private Sub insertRecMainDB(ByVal typeOfOrder As String) 'This sub will insert a new record of type O (Ordered) and put in all values from the table Order 'Also it will make a duplicate record of type R (Received) and put in same values so when later 'if there are no changes (meaning all product was received) no entry has to occur, however if you 'are missing a part then you can enter how many on the other form.
Dim yesOrNo As String Dim tempSQL As String Dim rec As New ADODB.Recordset Dim orderAmountRec As New ADODB.Recordset Dim partNameRec As New ADODB.Recordset Dim numOfRecords As Integer Dim cnt As Integer
'Checks the type of order and either checks or does not check it in the DB If typeOfOrder = "O" Then yesOrNo = "yes" Else yesOrNo = "no" End If
'Counts the number of parts we have to order, saves it in numOfRecords rec.Open ("SELECT* FROM [Order]"), conn, adOpenStatic, adLockReadOnly numOfRecords = rec.RecordCount rec.Close 'Loop to transfer data from the table Order to the table MainDB For cnt = 1 To numOfRecords
'Gets the name of each part tempSQL = "SELECT [Description] FROM [Order] WHERE [PartNumber]=" + CStr(cnt) + ";" partNameRec.Open (tempSQL), conn, adOpenStatic, adLockReadOnly
'Gets the amount ordered of that part tempSQL = "SELECT [MaterialOrdered] FROM [Order] WHERE [PartNumber]=" + CStr(cnt) + ";" orderAmountRec.Open (tempSQL), conn, adOpenStatic, adLockReadOnly
'Updates that part name with the ordered amount tempSQL = "UPDATE [MainDB] SET [" + CStr(partNameRec.Fields(0)) + "]=" + CStr(orderAmountRec.Fields(0)) + " WHERE [OrderNumber]=" + CStr(txtOrderNumber.Value) + " AND [DateTime]='" + CStr(lblDateTime.Caption) + "' AND [TypeOfOrder]='" + typeOfOrder + "';" CurrentDb.Execute (tempSQL)
partNameRec.Close orderAmountRec.Close Next End Sub
on a small scale this code works, but when my inventory table has all of the 2000 records it crashes, any ideas. I can ftp my database if needed
Code: Dim ColorDim StartPointDim RsItem As DAO.RecordsetDim RsNewItem As DAO.Recordset 'Grab the inventorySet RsItem = CurrentDb.OpenRecordset("select ItemId,Description1,description2,quantityonhand from item")'grab the table that will have the new item and description addedSet RsNewItem = CurrentDb.OpenRecordset("select * from newitems") With RsItem While Not .EOF StartPoint = 1Start:'find out if the last numbers is numeric or notIf IsNumeric(Mid(Right(.Fields!itemid, StartPoint), 1, 1)) = True Then'see if the start point is the last letter or notIf StartPoint = 1 Then 'meaning there is no colour indicated at the end of item Else'add the quantity and the color to the newItem tableColor = Right(.Fields!itemid, StartPoint - 1)RsNewItem.AddNewRsNewItem!Description = .Fields!quantityOnHand & ColorRsNewItem!itemid = .Fields!itemidRsNewItem.UpdateEnd If Else'move the startpoint to the next letter in itemStartPoint = StartPoint + 1GoTo StartEnd If .MoveNextWendEnd With
I have a bound form with a few fields. I would like to run a sub after some of these fields are modified, but not others. I would like it to run only once, after user finishes his work on the form.
When using the Unload event - the form on the form is not there anymore (or did I get something wrong?).
Is there a way to trap Data on form just before the form closes?
I need to know is there any specific code that would establish link for tables from Access BE?
I know it using Get External Data...Link Tables. Even though they are in other db but it leads to increase heavy size of main db. I want no table objects (except system tables) to be displayed in main db and only link tables once main db activates and should no table remain exists in FE after closing.
There should be some way to establish connectivity of tables from Access BE at the time of opening main db . This will help a ton to reduce the size of main db and its zip file can be copied even in a 1.44 mb floppy.
I heard something about shell but exactly I don't know how to do it.
Hi there, Thank you for this great site, and a special thanks to all persons here who are giving a big help to newbees as me. here is my prob: I have set up some few ASP pages using dreamweaver 8 in wich I put some forms to collect data from users (actually I'm recruting subjects for a scientific research) and teste them on my local host using IIS server and access 2000 database. all things work correctly. My strconnection in my local machin is as follow: Code:<%' FileName="Connection_ado_conn_string.htm"' Type="ADO" ' DesigntimeType="ADO"' HTTP="true"' Catalog=""' Schema=""MM_connsujets_STRING = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:InetpubwwwrootSujetsRecdbRecruSujets .mdb; Persist Security Info=False"%> I have found a site (http://www.asphost4free.com) wich host free asp pages. I uploaded my pages but the connection to the data base is no longer working. the host site give this sample of code to get to connect to the data base: Dim Conn Set Conn = Server.CreateObject("ADODB.Connection") strConnection = "DRIVER=Microsoft Access Driver(*.mdb);DBQ=" & Server.MapPath("/USERNAME/db/yourdatabase.mdb") oConn.Open(strConnection) .... ... oConn.Close I have follwed it and I have changed the username and the database name with mine but I can't figure out what to put to replace the .... after oConn.open. I git error this error when I have tryed to connect: Microsoft VBScript runtime error '800a01a8'
Object required: 'oConn'
/kin2006/Connections/connsujets.asp, line 11
I deleted the oconn but it doesn't help I have tryed many other combination without any success. Any clue!! thanks in advance
Hi I need code to open TeacherDetailFrm form Main form.
I have TeacherStudentSubFr*m on the Mainform, FirstNameTxt on the TeacherStudentSubFr*m, and TeacherDetailFrm. I need code to open the TeacherDetailFrm By double click on the FirstNameTxt.
I use this code but no data come and query dialog box come.
Private Sub FirstNameTxt_DblCli*ck(Cancel As Integer) Dim DocSubForm As String Dim DocText As String DocSubForm = "TeacherDetailFrm" 'DocText = "[Result]=" & "'" & Me![result] & "'" DoCmd.OpenForm DocSubForm, , , "[ FirstNameFld ]=forms![TeacherStudentSubFrm]![ FirstNameTxt]"
End Sub
I like to upload the file but no way in this forum
When I send a database to server it changes all of my special charters to unicod charterset, I suposed that server is on american charter set, I would like it to change to central europien windows - 1250 code page, is it posible and how? it is very importand to me. thx
Through word of mouth I hear that you can creat a link that can go from Access and link to the personal company system. Is this true? If it is, is there a standard code to use?
I am creating a report that has the variable address as usual. Name Address1 Address2 City, State zipcode
If there is no value for address2, is it possible to shift the locatoin of city state zip up into the Address 2 location? I would like to shift the lable up with code, but can't find a way to do it.
I am using an unbound data source so i have full control over the variable data.
I have an excel file, and am trying to import it, and once when I have imported it, am checking for a condition with While Not rs.EOF, it works fine for the purpose of looping, but it does not stop when the records are over., it is additionaly printing 19 null statements, where I beleive it, should not be.
I want to import HTML data which I get with email, to MS Access (2007). The problem is that files are badly formatted and standard import options are not avaliable for me.Basicly part of a file looks like that:
Before and after that there are many lines of code which is useless to me. Is there a way to access "Name", connect it to a row in my Access table and insert it's value (John) into the table?
Using an example:I have three tables; tbl_weight , tbl_height , tbl_bmi...How do I make tbl_bmi automatically use the weight and height values (height/ weight) to determine the tbl_bmi values? Is there a way to store code behind the tables as if I was in MS excel?