Search results

  1. ritchieroo

    A book on VBA

    Paul Lomax's "VB & VBA In a Nutshell" is an excellent book, and is a very informative reference for the general use of VB/VBA. The bulk of the book is a function by function reference, with syntax, examples of use, tips and pitfalls. The first few chapters cover programming structure and best...
  2. ritchieroo

    tabledef becomes invalid

    The problem is using CurrentDb directly. Here's what the help file says about the funtion: You can either declare a Database object, and set it equal to CurrentDB. Or, use the DAO collection directly, i.e. DBEngine(0)(0). I got this code working With DBEngine(0)(0).TableDefs("tblTest")...
  3. ritchieroo

    damn image n combo's

    Assuming that your main code for hiding/showing images is in the the combos AfterUpdate event, You should fire that event from the Form_Current event: Private Sub Form_Current() Combo1_AfterUpdate End Sub The form current event should fire when you navigate to a new record.
  4. ritchieroo

    Deleting Tables

    see editted version of previous reply for better way to detect system objects
  5. ritchieroo

    Deleting Tables

    Use this... dbs.TableDefs(index).Name Like "MSys*" also safer to test for non-system tables like this... dbs.TableDefs(index).Attributes And dbSystemObject = 0
  6. ritchieroo

    Need help with creating files from templates

    Here's the basis for recreating query... With CurrentDb On Error Resume Next .QueryDefs.Delete "qryTest" On Error GoTo 0 .CreateQueryDef "qryTest", "select * from [Table1] where [idWhatever] = " & lID End With You should be able to get the merge code from MSDN as suggested.
  7. ritchieroo

    Need help with creating files from templates

    Assuming that your Word Document is pulling data from a query within Access you could set up a loop that does the following apologies for pseudo-code: begin-loop "Create source query to return a single row of data, different criteria each time" "Open Word Document that is linked to source...
  8. ritchieroo

    RecordCount not working properly

    The "RecordCount" property gives you the number of records in total in the recordset, not the current position. You need to use the "AbsolutePosition" property. You should probably think about what would happen if there were more than one match. TIP: You loop through every record until you...
  9. ritchieroo

    TIP: Storing Images in Access

    While it is always preferrable not to store images in Access databases, there may be times when you might need to. There seems to have been a bit of discussion about this topic recently so I thought I'd post my code for doing this. Firstly, I should point out that I use BLOBs (Long Binary...
  10. ritchieroo

    ActiveX.

    Are you linking or embedding? Storing a BMP as and OLE object is fairly inefficient... embedding a image stores all the image data as well as a lot of data needed to tell the system what type of data it is, i.e. a bitmap, and how to launch it (OLE data) In a quick test I discovered that it...
  11. ritchieroo

    VB Coding Help Needed

    I'm assuming that you have a good business reason for needing to create physically separate tables, rather than just adding a the class# column to two tables (modelling logical tables). Your approach may cause you a lot a grief, and become difficult to maintain at some point in the future...
  12. ritchieroo

    How to edit a text file from vba

    Traditional VB I/O method... Dim hFile as Long Dim sLine as String hFile = FreeFile Open "c:\Whatever.txt" For Random As #hFile Do Until EOF(hFile) Line Input #hFile, sLine '... Process sLine Loop Close #hFile There are also more up to date methods such as TextStream objects...
  13. ritchieroo

    Has anyone else had this problem

    The Date datatype is a fairly recent addition to VBA, I'm guessing the problem machines are using a really old version of the VBA library. In the abscence of this datatype Date would be interpreted as the function Date(). Take a look at your references, try to find out what version of the VBA...
  14. ritchieroo

    Has anyone else had this problem

    The Short Date Format is picked up from the client machine's regional settings Use the Control Panel on the effected machines, or have a look for the following Registry Key: HKEY_CURRENT_USER/Control Panel/International/sShortDate This of course will only tell you what's going on... the...
  15. ritchieroo

    List Box Rowsource

    VB6 offers the Join function which will do this easily, but it is missing from VBA (unless it's been added to more recent versions). If you don't have it try this replacement... Public Function Join(ByVal SourceArray As Variant, _ Optional ByVal Delimiter As Variant) As String Dim sJoin...
  16. ritchieroo

    HOW DO I?: Arrays - Assigning

    This should do it Call test(udtExample) or just... test udtExample
  17. ritchieroo

    Null Problem....

    Handling Nulls It's a good idea to decide on a strategy for coping with Nulls early on in the development process, and then stick to it. Your options are: to convert all Nulls to something valid, i.e. empty-strings for string-variables or zeros for numerics; to use nulls throughout (my...
  18. ritchieroo

    HOW DO I?: Arrays - Assigning

    Public Type TMyStruct Action As String Form(1 To 3) As Form TableName(1 To 3) As String FieldName(1 To 2) As String Field(1 To 2) As Control End Type Public udtExample As TMyStruct .... Set udtExample.Form(1) = FrmXYZ
  19. ritchieroo

    Disable the Function Keys

    1. leaver off function key buttons with screw-driver 2. Put a small blob of super-glue at base of each key 3. Allow glue to harden 4. Replace buttons voila! Function Keys disabled
  20. ritchieroo

    Old code = old date

    Set a reference to Microsoft Scripting Runtime... the File object exposes a DateCreated Property Public Function GetFileCreatedDate(ByVal Filename As String) As Date Dim oFSO As Scripting.FileSystemObject Set oFSO = New Scripting.FileSystemObject GetFileCreatedDate =...
Back
Top Bottom