Search results

  1. T

    Options for calling a subroutine

    Imagine I have two subrountines: Private Sub DoSomething1() [Do Something] End Sub Private Sub DoSomething2() [Do Something] End Sub And this Declaration: Dim str As String str = 1 Is it possible to refer to/call one of these subroutines using something like this: ("DoSomething" & str)...
  2. T

    Problem with Control Declaration?

    Hi everyone. Happy New Year to you all. I'm working on a user form that has a number of check boxes on the left. On the right hand side there are two text boxes for each check box. When a check box is ticked (set to true) the two text boxes on the right hand side become active. Rather than...
  3. T

    Access to Excel - inserting rows

    Hello everyone, I'm trying to add two rows to the top of an Excel worksheet "qryCFP" from a workbook using the following vba code from Access: Excel.Application.Workbooks("Path").Worksheets.("Sheet1").Rows.Insert I get the error message "subscript out of range." I realize that the code above...
  4. T

    Maximum Value in Excel Column From Access

    Hi I'm using Excel vba for the first time and I'm trying to find the maxium value in the column AI (No. 35) in an Excel spreadsheet FROM Access. So I've got: Dim appExcel As Object Dim datLast As Date Set appExcel = CreateObject("Excel.Application") datLast =...
  5. T

    Field Names in Functions

    Hello everyone, I think this is a vba question at heart so I've posted this here. Adding fields into a function has been a problem for me: IIf((Count([qryADDR].[Fuel Type]>2), 'MPS', [qryADDR].[Fuel Type]) The logic I'm trying to create is the following: If the number of Fuel Types is...
  6. T

    SUM Query Data Type Mismatch

    Hello everyone, I think this is a vba question at heart so I've posted this here. I'm trying to use this in a query: SELECT [Table]., SUM(CDbl([Table].[Field])) AS [New Field] FROM Table GROUP BY [Table].[Code] The CDbl() is used because the original value for [Table].[Field] is of the...
  7. T

    Loop through recordset not recognizing .MoveNext?

    Hello, So I have a table "zztblArticles." Some fields should go to "tblArticles" and values in Tag_ID should go to a lookup table "tblTag" and a junction table "tblArticles_Tags." I'll explain the code I've written below: Private Sub cmdSubmit_Click() Dim db As Database Dim...
  8. T

    Working with Listboxes

    Listboxes. If I select some values from a list box, I would like to be able to use them in Visual Basic. It seems it is a little more complicated than declaring variables form a textbox. Does any one know how to work with Listbox values in VB? I would like to get the values and execute an...
  9. T

    RElationships and different dataset types.

    Hello Quick question: Say I have two different dataset types. Type A cam be stored in two tables, a main data table (call it Main_Data) and a metadata (Call it Metadata) table which contains information on Main_Data. There would be a one to many relationship between the relevant parent...
  10. T

    Min in Default Value

    Hi everyone. Expressions in Access have given me some trouble before. Mainly due to inexperience. I hardly ever work with them. What I am trying to do is make the default value of a form textbox control the minimum value of a field A in a table A.The datatype of Field A is Date. So far I've...
  11. T

    Database relationships

    This might seem like a stupid question, but is the general rule for a relationships between fields (one to many specifically) only one relationship per pair of fields? Will it cause problems if you have a field linked to two fields each through a one to many relationship? Thanks!
  12. T

    WriteAllText

    I'm trying to use the WriteAllText method to write a text file based on some values in my database. ' Declaring Header Dim Header As String Header = "Line 1" & _ "Line 2" & _ "Line 3" ' Writing Text to file My.Computer.FileSystem.WriteAllText("[Pathway]", Header, True) End Sub The debugger...
  13. T

    Record by record query

    Hello everyone, I have an append query that I would like to use to distribute records to a variety of databases. Some records will go to one, others to a second and so on. I have an idea as to how this would work in Visual Basic, but how can I make an append query work through a table on a...
  14. T

    Querying a multivalue field.

    A have a query that selects a multivalue field. The query forms the record source for a subform. The text values in the multivalue field are displayed in the query, but when I save this and view the data in the subform datasheet view the values revert to the primary key values. They are 1,2,3,4...
  15. T

    Update Query on Multivalue field

    I have a multivalue field containing values of A,B,C and D with primary IDs of 1,2,3 and 4 in that order. If I was to run: UPDATE Table Set Table.Multivalue.Value = 1 WHERE Field 1 = "True" AND Field 2 = "True"; Then run UPDATE Table Set Table.Multivalue.Value = 2 WHERE Field 1 = "True" AND...
  16. T

    NOT NULL Values for Dates

    Hi again I have a text box with a date picker in a form. I need to create a piece of conditional logic in Visual Basic that is activated when the value in the form is not null. I can't so this in the same way as I would with a string which would be: If Field <> "" Then Statement End If Does...
  17. T

    Dynamic SQL - Missing Parameter

    I've attempted to create a form with a dynamic subform. Records for the subform are filtered using check boxes which supplies parameters to the Visual Basic script (below). The VB Script changes the Record Source (SQL) of the subform. Checkbox variables are defined/declared: Private Sub...
  18. T

    Older than/ New than with Dates

    Hello I've built an an update query that updates a Yes/No field "Expired?" to "Yes" if the expiration date has passed i.e. if the current date is newer than the expiration date. I thought this would translate into the current date being greater than the expiration date? UPDATE Alert SET...
  19. T

    DateAdd Function using existing field values

    I have a query in design view that consists of two calculated fields at the moment. One of the calculated fields is supposed to add one year onto a value from another date/time field called "Last_Date." The expression I've written in the "Field:" box in Query design view is Expr 2...
  20. T

    Expression builder, forms and nested expressions

    OK, so I assume the MS Access "Expression Builder" works in SQL. I understand the Expression Builder allows for conditional logic with the iif function. My questions are: Can you create nested iif functions like you can in Visual Basic? If so, how? Do you just replace value if true and...
Top Bottom