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.
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.
The Name_ID in each Donor Table points back to the Name_ID in Table1.
What I want to do is get a list of the Name, Address, Item and Item_Description for any record found on either Table2, Table3 and Table4 and then sort the result set by Name.
My tables are all very small – 100 entries at most on any 1 table.
My queries so far are returning 40,000 and 50,000 records – I assume because I am writing SQL that forces sub-queries.
I am more familiar with SQL using Where Tbl2_Name_ID equals Tbl1_Name_ID or Tbl3_Name_ID equals Tbl1_Name_ID or etc rather than inner joins or left joins so I am struggling.
I know this has to be elementary, but I am missing it.
I'm trying to show an overview of the green and red cars which were bought in june or before, ordered on price, I have this:
SELECT car.carname, car.colour, car.Bdate, car.price FROM car WHERE (((car.colour)='red') AND ((car.Bdate)<6)) OR (((car.colour)='purple')) ORDER BY car.price;
It works all except for the <6 part (doesn't work with =<6 etc either). The month is only used in this column and represented by a number i.e. 6.
I hope this is clear and I hope somebody can help me with my problem!
I have a listbox that populates it's values from a table. Upon the click() event, I run a script to determine the current record for the rest of the form. One of which is an TextBox bound a field in the table the ListBox is populated from.
I store the old values in the Form_Current() method, and allow the user to change the values in the TextBox, and upon textbox_change() I enable an 'Apply' command button.
When the Apply Button is pushed, I set the "saved" data to the actual current data (since the control is bound to a record field), and thus the changes are fully applied. However, I cannot seem to get the ListBox to update it's 'text' display to represent the changed value from the textbox. I have tried ListBox.requery, but it doesn't work instantly...it sometimes is delayed until I change "apply" a new set of changes.
Why is this?
Specifics: Table AreaID (AutoNumber) Area (Text)
Query Table.*
AreaList.RowSource = Table AreaEdit.ControlSource = Area
Private Sub AreaEdit_Change() Dim St As String St = AreaEdit.Text Debug.Print "Chg Text: " & St Call UpdateChanges(True) End Sub
Private Sub UpdateChanges(ByVal Value As Boolean) ChangesMade = Value ApplyBtn.Enabled = ChangesMade End Sub
Private Sub ApplyBtn_Click() AreaList.SetFocus 'this is because you can't disable a control (the applybtn) when it has the focus AreaList.Requery '<==== THis is supposed to repopulate the listbox, but it doesn't do it. Call Form_Current 'this just stores the current values of the actual record into temp variables Call UpdateChanges(False) End Sub
hi ..had a quick search through the pages, no luck.
i have 8 check boxes on my Search form. If i check one of them...i want to send certain text to a field. is this possible? eg: i have 8 check boxes with different project names, if i check my check box named "Laem Supot" i want the the text "Laem Supot" to be sent to my Project Field on my listbox.
i found a similar for a date value:
Me.yourcontrolname.Value = date() .....(would this work and how do i implement it)
however i may need to check 2 or more check boxes, therefore i can't send 2 project names to one field. My clients may be associated with 2 or more projects, how do i show this or represent this in my SEARCH FORM.
Im trying to figure out how to model 'Printer' and 'Cartridge' information. The relationship between them is Many to Many, but to add to my confusion, more than one cartridge can be used in a printer (Black + different colour cartridges). Adding a new entity to resolve the Many to Many does not solve this issue of how a printer can have, for example, a black cartridge and 3 different coloured cartridges.
Any ideas how to model this please?? I have been toiling with it for some time and I keep going round in circles :confused:
I'm sure it shouldn't be as difficult as it seems, so I'm hopeful someone might be able to set me straight :o
I have been unsure about this topic and want to finally be sure.
When I create a lookup table I don't include a PK; I just have the one field. Therefore I don't include an FK within the Main table; I include the same field name as the field name in the lookup. "sector Details" in lookup and "sector Details" in Main.
Am I better to make up these lookup tables and use a PK and then have the FK within the Main Table? Is this easier or trickier to work with? And will it cause any problems if I did include keys? for example, providing combo boxes as search criteira for forms using the FK/PK as bound fields?
I know it's a bad idea to have lookup fields in tables which I'll avoid. But this means if I'm updating in the back end I'll only see a table full of keys and not the field name!
Hope someone can help because I've been getting different advice since I started on Access including Professional books using lookup fields.
I have a series of append queries that run when a database opens, to copy over the contents of various log files into a single table.
Each record has a field, [1-DateTime], which (surprisingly!) contains a date/time. When I open the linked text files from Access, these appear absolutely fine, all in US format (mm/dd/yyyy hh:nn:ss). But when I run the append query, it gets all confused, and puts them into my table in a conbination of formats!
Those that it can recognise as UK dates (e.g. 01/05/06) it stores as 1st May 2006, but then it gets to 01/22/06 and it decides that they must be US dates, so stores them (CORRECTLY) as 22nd January 2006.
I have been doing some experimentation with Queries and I have discovered something unusual.
If I have one query and I use the totals feature (only using group by) I get all the records based on the inputed criteria
If I then use that same query as an underlying recordset for a second query and I use the totals feature (only using group by) in the second query... I only get the first record of each type. See query results below..
I am trying to achieve the results of the second query in the first query (DON'T WANT NESTED Queries) and I don't really understand why the results of the queries are different when everything else is the same other than one being nested.
Example below
First Query Results (using totals with group by)
1 a 1 a 1 a 2 a 2 a 2 a 3 a 3 a 3 a 4 a 4 a 5 a
Second Query Results with the First query as its recordset (using Group By)
I do have questions about tabular subforms. I have created several forms and I thought that they were linked together. The main form (GSI) is general information about each site that we visit. The tabbed forms are about various survey's done on a site. So, what I thought would happen is; I'd fill out the info on the GSI forms about each site. I'd go back after doing a survey, look up that site, click on the corresponding survey tab and add information about that survey and It would link back to the site on the GSI. What is happening is, when I pull up a site and add survey data the same survey data comes up in the next site also. I think, the problem is,
I have a switchboard with Add new site and Edit site. When I go into Edit site and I do a search by Site name, it pulls up the name, but not the record, so I'm just changing the site name by doing it that way. If I move down to the bottom of the form and scroll or move through the records that way it works right, but I need it to be more user friendly. I'm sure that there is a statement I could create to do this, but I'm not knowledgeable enough to know what it is. :confused:
I'm running Access 2000 through Citrix, 20 users internationally from 1 db. I'm working through Citrix network issues to split db with separate FE's for each user. I have sporadic corruption due to this. But this morning I met a new breed of corruption. I preface this with the fact that I run a bat file nightly to do clean up and compact and repair the db. It verifies the db is not in use prior to running. This morning we were presented with a hosed db. The log file said updates ran fine. In my main table the first record was garbage, including the Auto-num field. I found that my Primary key has lost it's index and references had become unchecked. Correcting these issues got it running but does anyone have any clue what might have triggered this or even where I should start looking? Please help as I am at a loss. Thanks.
In OPTIONS -> Advanced I have the option Open Database using Record-Level locking ticked.
What is strange is record level locking works on Form1 (Form1.recordlocks= Edited) as long as Form2 has Form2.recordlocks = No Locks. If I change the Form2.recordlocks = Edited, Form1's locking becomes page level locking.
This is even true if Form2 is not open...
Additionally, Form2's locking is always page level locking if Form2.recordlock = edited.
I would like all my forms to perform RECORD level locking not page Level locking. How do I accomplish this.
I've been trying to resolve this issue for about 2 months now but no answers from the community.
hello, this is frazzling my brain i cannot comprhend the answer :confused: sorry werent sure were 2 post this hope this is the right place
I have an array of comics 300 they come out weekly, the first is Number: 344 this came out 26th September 1983, i have a form with a combo box were i select the comic number (344 - 700+) in this case i am selecting 344 and i press a button "command 11", i would like it to display in three text fields, date, month and year. This has well an truly killed off my brain. Any help would dearly be appreciated. Need any further information just ask. Paul
I have created a database in Access XP (2002). In a nutshell, the database records numbers of people attending a seminar; which can take place any number of times per week, and so hence can take place any number of times per month.
I have set up the query so that it can run immediately after a seminar to show the attendants who attended the seminar on that current date "Date()" in the criteria box. However, how would I go about setting it up so that it shows who attended every seminar in the current week or month?
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 have a main form [mainform] with several subforms on it, two of which are on a tab.
On the second tab [page79] there is a subform [subformlist] which has like 25 checkboxes on it, any combonation of which can be picked by the user.
I need there to be at least one pick required of this subform, else the record won't show in a general query I have, since the table the subform is based on is linked to the record.
Is there anyway to make making a choice of one of at least one of these checkboxes checked a manditory thing before the user can close or move on to the next record?
I've tried making an "Other" box that on the Table has a default value of "True" which I thought would cause it to show in the query record...to no avail.
The only true way to make this work is to have it mandatory that the user pick from AT LEAST one, usually more before the record is complete.
Any help? Other than writing a MASSIVE If...Then statement...?
Or is there a way to make it so the choice isn't required for the record to show up in the query?
I'd post...but my db is too massive, even zipped. :(
I have a DB in .mdb format which works perfectly and when all the code is compiled it results in no problems. However. When I convert this to a .mde file, it doesn't work at all and it suggests that there are compile errors where there weren't any before! Please can anyone suggest what the problem might be as I don't particularly want to run this as a .mdb. Thanks
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 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?