below is the code I am using to update multiple records on a sub form so that QtyReceived=QtyOrdered when you click the ReceiveButton, now my understanding of VBA is a little limited and the code I'm using won't work in my main form "frmReceiving" only in the subform "frmReceivingSubform" can anyone see what I'm doing wrong?
Private Sub ReceiveButton_Click()
Dim rs As DAO.Recordset
Set rs = Me.frmReceivingSubform.RecordsetClone
With rs
.MoveFirst
Do While Not .EOF
If rs("QtyReceived") = 0 Then
.Edit
rs("QtyReceived") = [QtyOrdered]
.Update
End If
.MoveNext
Loop
Set Conn = Server.CreateObject("ADODB.Connection") Conn.Open("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath(" coordinatordbTC.mdb")& ";PASSWORD=123456") ================================================== ===================================
I have been trying solve this problem for a few days. however, the best i can come into is the above code, however , the following error still approached me.
================================================== =================================== Microsoft JET Database Engine error '80040e4d'
Cannot start your application. The workgroup information file is missing or opened exclusively by another user.
Is Query of 'RecordsetClone' possible? (.mdb database on desktop/laptop - single user - no servers) I want to run an update query on a form's underlying query/filters in VB - i.e. the RecordsetClone. I cannot use the query for the form as the fields used by the query have been changed. Logically, what I need to do is below, in the code fragment. Set rst = Me.RecordsetClone Set qdf = dbs.CreateQueryDef("", "UPDATE rst SET rst.Checked = " & bool & " ;") qdf.Execute Microsoft Jet doesn't recognize 'rst' in the sql statement, and this fails. Travis
I have a quick question. I have a main form with a label and a button on it. When the button is pressed a secondary form pops up. The second form has a button on it also. I am trying to code the button on the second from so that when it is pressed the label changes its value on the first form. In the past it was quite easy as there was no second form so in the Onclick VB coding of the button on the first form had something like:
With Me.mainHeading .caption = "Recontacts" End With
But, with the secondary form, the "Me." does not work. Is there a way i can replace the "Me." with some sort of link back to the first form?
I have several list boxes, and each is populated using a query source. I want to make it so that when you double click a given entry it pops up either a form or query that says more information on the item.
Each list box is populated using two fields from the query a name and a number.
Example
Item A | Value A Item B | Value B Item C | Value C
I want it so if you were to double click Item A a form opens with the rest of the information so a text box or whatever with the following
Item A Value A AnotherValue A Etc A ....
Basically I want to be able to pop up a single line of the query based on double clicking of the list box entry.
This is what I have so far in code:
Code: Private Sub prospectLW_DblClick(Blah As Integer) Dim varItem As VariantDim strPlayer As String strPlayer = Me.prospectLW.ItemsSelected.Item(varItem) MsgBox strPlayer DoCmd.OpenForm ("Popup1") End Sub
The trouble I am having is getting the value from the listbox if I can get say Item A when you double click it ignoring the other info I want just the name of "Item A" so that when I open the form I can use that variable to filter the form I made that is basically just the query within a form. I hope that is enough information if not let me know I can add more.
I have a form (see attached) and every time someone goes to a different field I would like to change the border to red and when they leave that field to change the border back to the default color. I know I can put the code in for each fields got focus and lost focus section but would rather be able to put the code in once and for it to work for all the fields.
I search a record with values that I am taken from form1 . If i found the record i show it on the form2 else I add a new record to table with values that i am taken them form form. this is my code: Code: Dim stDocName As String Dim stLinkCriteria As String stDocName = "mainhazineh_m" DoCmd.OpenForm stDocName, , , stLinkCriteria Form_mainhazineh_m.mahp.Value = Form_mainform_m.Combo2.Value Form_mainhazineh_m.salp.Value = Form_mainform_m.Combo0.Value Form_mainhazineh_m.RecordsetClone.findfirst "[salp]= " & Form_mainform_m.Combo0.Value & " And [mahp]= " & Form_mainform_m.Combo2.Value & " And [shahrp]= '" & Form_mainform_m.Combo12.Value & "'" If Form_mainhazineh_m.RecordsetClone.RecordCount <> 0 And Form_mainhazineh_m.RecordsetClone.NoMatch = False Then Form_mainhazineh_m.RecordsetClone.edit Form_mainhazineh_m.RecordSelectors = True Form_mainhazineh_m.Bookmark = Form_mainhazineh_m.RecordsetClone.Bookmark Form_mainhazineh_m.RecordsetClone.Update Else Form_mainhazineh_m.RecordsetClone.AddNew Form_mainhazineh_m.mahp.Value = Form_mainform_m.Combo2.Value Form_mainhazineh_m.salp.Value = Form_mainform_m.Combo0.Value Form_mainhazineh_m.shahrp.Value = Form_mainform_m.Combo12.Value Form_mainhazineh_m.RecordsetClone.Update Form_mainhazineh_m.Bookmark = Form_mainhazineh_m.RecordsetClone.LastModified End If my problem is that when i must add new record to db, it only change the first record of table with values that i make them red then add a new record that all fields of it is empty. can anyone help me ?
I have 2 tables, (will just call them tbl1 and tbl2 for this example) each with a column AppNumber. The AppNumber may appear in both tables or individually in either one.
I want to be able to show, or flag, on a continuous form which Appnumber's appear on tbl1, tbl2 and on both. This is so the user can click a button and bring up another form with more data relevant to the AppNumber.
I have written a union query to show all results from both tbl1 and tbl2 which contains 4 fields AppNumber, DateApp, Surname, Forename but I can't tell from the query results what AppNumber's appear on each table. Here's what I would like to show on the continuous form:
AppNumber DateApp Surname Forename tbl1 tbl2 Both 12345 11/12/2012 Simpson Homer Yes No No 56565 01/04/2013 Stallone Sly No Yes No 89788 03/03/2012 Rambo John Yes Yes Yes 89745
When attempting to select a letter in a form copied from the Northwind's Customer Phone List Form, I am now getting an error message that says "The object doesn't contain the Automation object "RecordsetClone'". I never had that problem before. Appears to be something in the Option Group that has gone awry, but I cannot access the Visual Basics behind the Macro. Is there a way to suppress this message? It does not appear to be a problem in bringing up the sought after page. :confused: :confused: Please help!!
I have used Combo box. security_level field is the one that describes their levels and there are only two levels 1 and 2.. I have a table called User (user_ ID, User_Name, Password, Security_Level) On form there is a combo box for user name and text box for password. Two command button where one is for EXIT (Closing the application) and the second button is to run the code.
if the password in table User matches value chosen in combo box or user name and password are correct Then it should check if Security_Level of the user is equal to 1 to displays a form called Admin and when the Security_Level of the user is equal to 2 to display a form called user1.All that I want is to have a login that has two user and each user when login opens his/her own form which is different from the other user.
I have a Form that currently contains a checkbox that has the following OnClick event... SELECT tblPlayerRegister.Surname,tblPlayerRegister.[Club],tblPlayerRegister.Age FROM tblPlayerRegister WHERE (((tblPlayerRegister.Age) < 11) And ((tblPlayerRegister.Club) = "Beaconsfield")) ORDER BY tblPlayerRegister.Surname;
The aim of this is to select the Surname, Club & Age from the Table PlayerRegister where the Age is less than 11 and the Club is 'Beaconsfield' and then Sort in Ascending Order by Surname. I get an error when I write this code and I don't know what I am doing wrong. I am not very knowledgable with Coding but I have given it a go. There will eventually be many checkboxes with different criteria and I don't want to do a query for every one. Could somebody please advise what I have done wrong? Thank-you for any assistance given.
Okay here is my code, I had thread open awhile back. In regards of exporting main form and subform to word. Here is the code, I am still having problem with it. I can't seen to take export nothing or if I switch around dbs.close and rs.close, I end up exporting whole subform (meaning all the selected text from all the records to on one word doc. I don't know what I am missing, and it has gone beyond the limits and I have turn my brain upside down, but still no answer :( It has to be something with coding. Because, I know my subform is working fine, if I print out a report on access. Help me out plz.
TIA
Private Sub Command4_Click()
'Declare the follwing Dim dbs As Database Dim objDocs As Object Dim objWord As Word.Application Dim prps As Object Dim rst As Recordset Dim blnSaveNameFail As Boolean Dim BorrowerID As String Dim InformationID As Long Dim intcount As Integer
'Set word as an application and make it invisible Set objWord = CreateObject("Word.Application") objWord.Visible = True 'True is visible
'path and name of the template your are using. objWord.Documents.Add ("C:Temp ermsheet3.dot")
'This is for the bookmark that you created in the template objWord.ActiveDocument.Bookmarks("bmCusadd").Select
'This is the field in access that containts the data that has to be entered at the 'bookmark objWord.Selection.Text = Forms![menu]![txtCusDetails]
If intcount < 1 Then MsgBox "No detail items for invoice; canceling" Exit Sub End If Set dbs = CurrentDb Set rst = dbs.OpenRecordset("tmakInvoice", dbOpenDynaset) With rst .MoveFirst Do While Not .EOF BorrowerID = Nz(![Borrower ID]) Debug.Print "[Borrower ID]:" & BorrowerID With objWord.Selection .TypeText Text:=BorrowerID .MoveDown Unit:=wdLine, Count:=2 '.MoveRight Unit:=wdCell End With .MoveNext Loop .Close End With
With objWord.Selection .GoTo what:=wdGoToTable, which:=wdGoToFirst, Count:=3, Name:="" .MoveDown Unit:=wdLine, Count:=1 End With dbs.Close objWord.ActiveDocument.Fields.Update
'Word (or the document that you created with the template, will now open) objWord.Visible = True
Set objWord = Nothing 'rst.Close Exit Sub 'End With
Hey, i need help with a code. It shouldn't be too hard but i don't know where to start as i am unskilled on this program.
I am looking for an input box saying 'enter password here' to pop-up. If it is the same as say 'customer' then i want it to let the user into another form.
I just created a database for work, its got two fields on the form, item and Price.
What i want it to do is when I enter the amount of item, I want it to automatically work out (price = £3.99)the price per item and display it on the Price text box on access.
I done VB but cant remember much, i Know u might have to do a IF statement.
trying to make it so that when you open the report, it'll pop a dialog box for users to choose the dates (from date to to date. ie. 04/15/05 to 07/17/05). When I click on the report, dialog shows up fine but it finds every record... can someone please help me with this.
here's the coding for the report
Option Compare Database Option Explicit
Public Sub cmdCancel_Click() ' Method in all forms to allow clean close DoCmd.Close acForm, Me.Name End Sub
Private Sub cmdPrint_Click() ' Validate the dates If Not IsDate(Me.txtFromDate) Then Me.txtFromDate.SetFocus MsgBox "You must enter a valid From date.", vbCritical, gstrAppTitle Exit Sub End If If Not IsDate(Me.txtToDate) Then Me.txtToDate.SetFocus MsgBox "You must enter a valid To date.", vbCritical, gstrAppTitle Exit Sub End If If Me.txtFromDate > Me.txtToDate Then Me.txtFromDate.SetFocus MsgBox "The From date must be less than or equal to the To date.", _ vbCritical, gstrAppTitle Exit Sub End If ' Hide me so the calling report can run Me.Visible = False
End Sub
Private Sub cmdToDateCal_Click() Dim varReturn As Variant ' Clicked the calendar icon asking for graphical help ' Put the focus on the control to be updated Me.txtToDate.SetFocus ' Call the get a date function - date only varReturn = GetDate(Me.txtToDate, True) End Sub
Private Sub Form_Open(Cancel As Integer) ' Set up the form caption Me.Caption = Me.OpenArgs ' Set up the label Me.lblTitle.Caption = "Select Dates for " & Me.OpenArgs End Sub
and coding for the form i designed.
Option Compare Database Option Explicit
Public Sub cmdCancel_Click() ' Method in all forms to allow clean close DoCmd.Close acForm, Me.Name End Sub
Private Sub cmdFromDateCal_Click() Dim varReturn As Variant ' Clicked the calendar icon asking for graphical help ' Put the focus on the control to be updated Me.txtFromDate.SetFocus ' Call the get a date function - date only varReturn = GetDate(Me.txtFromDate, True) End Sub
Private Sub cmdPrint_Click() ' Validate the dates If Not IsDate(Me.txtFromDate) Then Me.txtFromDate.SetFocus MsgBox "You must enter a valid From date.", vbCritical, gstrAppTitle Exit Sub End If If Not IsDate(Me.txtToDate) Then Me.txtToDate.SetFocus MsgBox "You must enter a valid To date.", vbCritical, gstrAppTitle Exit Sub End If If Me.txtFromDate > Me.txtToDate Then Me.txtFromDate.SetFocus MsgBox "The From date must be less than or equal to the To date.", _ vbCritical, gstrAppTitle Exit Sub End If ' Hide me so the calling report can run Me.Visible = False
End Sub
Private Sub Form_Open(Cancel As Integer) ' Set up the form caption Me.Caption = Me.OpenArgs ' Set up the label Me.lblTitle.Caption = "Select Dates for " & Me.OpenArgs End Sub
codings from Microsoft "Building Access Applications" viescas
Yesterday I was advised by 'Smart' on placing a certain code, as follows:
In the after update trigger of the combo box you can do the following
If YourCombobox = "-" Then yourtextfield.ForeColor = vbRed Else: yourtextfield.ForeColor = 0
End If __________________
Please forgive my ignorance but where do I put this code... on the line for 'after update' or in the code builder. If it is the latter, how do I begin the code because it has Private Sub and End Sub. I am obviously no expert but I'm just trying to plod along and learn as I go. Your help is gratefully accepted.
I want to track the shipping costs for my products (no commercial value) which I mail world wide. My fields are:
Product Name Product Weight Quantity Mailing Zone Unit mailing cost Total mailing cost
On my input form Product Name and Product Weight are input using a combo box. Quantity is entered manually.
I have a table listing my products and the unit cost (best price) to send them to various world mailing zones.
I want to create a combo box on the Mailing Zone field and code it so that when I select a Mail Zone, the Unit mailing cost field is updated with the correct value for the product.
I have a combo box (cmboType) and the options are (let's say) Cat1, Cat3, Dog4, Mouse5 (but there are about 30). If I select cat (any type)I then (manually) tick a Yes/No box.(chkYes)
How can I make the box picked ticked automatically whenever I select a cat in the combo box.
I am trying (on the afterupdate event of the combo box) something like
If cmboType is like "Ca*" then chkYes = true
Obviously this doen't work - can anyone help me with the correct code?
I have the following code that will import OLE objects into access, and it works quite well...but, how do I get it to check to see if a reocrd already exists and not to duplicate a reocrd? I am not a programmer, I have a couple of ideals but I don't know where to start. Any help would be appreciated.
If I were to put a new file into the folder, I would like the code to only import the new file and all files again. Which currently it will just create new reocrds for the existing document. I hope I have explained this... Any help would be appreciated. Thanks. vb Code: Original - vb Code Private Sub cmdLoadOLE_Click() Dim MyFolder As String Dim MyExt As String Dim MyPath As String Dim MyFile As String Dim strCriteria As String MyFolder = Me!SearchFolder ' Get the search path. MyPath = MyFolder & "" & "*." & [SearchExtension] ' Get the first file in the path containing the file extension. MyFile = Dir(MyPath, vbNormal) Do While Len(MyFile) <> 0 [OLEpath] = MyFolder & "" & MyFile [OLEFile].Class = [OLEClass] [OLEFile].OLETypeAllowed = acOLEEmbedded [OLEFile].SourceDoc = [OLEpath] [OLEFile].Action = acOLECreateEmbed ' Check for next OLE file in the folder. MyFile = Dir DoCmd.RunCommand acCmdRecordsGoToNew LoopEnd Sub Private Sub cmdLoadOLE_Click() Dim MyFolder As String Dim MyExt As String Dim MyPath As String Dim MyFile As String Dim strCriteria As String MyFolder = Me!SearchFolder ' Get the search path. MyPath = MyFolder & "" & "*." & [SearchExtension] ' Get the first file in the path containing the file extension. MyFile = Dir(MyPath, vbNormal) Do While Len(MyFile) <> 0 [OLEpath] = MyFolder & "" & MyFile [OLEFile].Class = [OLEClass] [OLEFile].OLETypeAllowed = acOLEEmbedded [OLEFile].SourceDoc = [OLEpath] [OLEFile].Action = acOLECreateEmbed ' Check for next OLE file in the folder. MyFile = Dir DoCmd.RunCommand acCmdRecordsGoToNew Loop End Sub
Yesterday I posted a question and rec'd good advice but as usual I don't think I explained myself very well. As the attached picture of my Form shows, I have a checkbox for each Age Group under each Team. I originally had a query that would come up for each Team's particular Age Group and then the required data copuld be input. This leads to too many querys clogging things up. I tried to copy the SQL code of one of the query's to the On_Click event of the checkbox but as I have been informed SQL is different to VB. All I would like to know is how to convert the SQL to VB coding so that I can continue to do the coding for each Checkbox. The SQL code for the first checkbox is:
SELECT tblPlayerRegister.Surname, tblPlayerRegister.[First Name], tblPlayerRegister.Age, tblPlayerRegister.[D'n], tblPlayerRegister.G1, tblPlayerRegister.SP, tblPlayerRegister.Age2, tblPlayerRegister.G1A FROM tblPlayerRegister WHERE (((tblPlayerRegister.Age)<11) AND ((tblPlayerRegister.Club)="Beaconsfield")) ORDER BY tblPlayerRegister.Surname, tblPlayerRegister.[First Name];
If there is an easier way, by all means let me know. Any assistance would be greatfully appreciated.
hi. I am trying to write a code to sum the total cost of all jobs that are selected as 'yes' in a combo box.
Once the user selects 'yes' in a combo box, they enter in a cost for that specific job. Each client may have 10s of jobs. I need to write a code that will sum up all the 'yes' selected jobs for a client. I know it should be an 'if' statement but I can't seem to get it to work. I need this value for a report. How would I do this and where would i put the code.
What I am trying to do is create 3 (or more) parameters for a query from a single table. Lets use this for example:
Table Name= "tblExample" Field Name "A" with Perameter "1" Field Name "B" with Perameter "2" Field Name "C" with Perameter "3" (All from Table= "tblExample")
My intentions are that when the query is run, the user is asked to include 3 subjects (1 subject per perameter; 3 perameters total that pop up). But I am having trouble making it so that if a random person using this query doesn't know or can't remember 1 or 2 of the subjects they are looking for, the query will just (in a sense) ignore the two blank parameters the user has left alone, and just clicked the "ok" button without entering anything, and use the 1 parameter that it was given a subject for, to filter/query out a result.
If you beleive you will have trouble explaining this to me, I'll use this as an example:
Table Name: "tblExample" Field Name: "A" with Parameter "1" Field Name: "B" with Parameter "2" Field Name: "C" with Parameter "3" (All from Table: "tblExample")
The user uses the query and is asked by the first parameter for input. The user isn't sure, and clicks ok without entering anything, and parameter 2 pops up. The user then enters a subject of which he/she knows to look for and clicks "ok". Then the final parameter asks the user for input, and the user again doesn't know, or can't remember so he/she just presses the "ok" button. What would be the coding for this kind of parameter that if nothing is entered, the parameter is ignored?
In desperate need of assistance. Thanks in advnace
&HFHEFEF, and &HFFEFFE and the like relating to certain colors: where is this magical "chart/table" of equivalents? Need soon..thanks..teball20 (teddy)
Need Help: Table has several fields, two that pertain to this question are:
[Time] and [AM/PM] User inputs both, values such as 11:00 am 11:30 am 12:10 pm I have to change the pm to am if the time is between 12:00 and 12:59. I have an update query that works but I want to place code in a report that does the same thing without using DoCmd.Open Query I would rather use an If statement. Please help. I placed this question in Microsoft and reply did not answer the question. Rather told me ampm would automatically show up. I knew that, but want to change the automatic pm for sorting purposes.