Results 1 to 2 of 2

Thread: SQL Recordset Specific Fields

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2003
    Posts
    7

    SQL Recordset Specific Fields

    I have written an SQL for form load so when the form starts it looks through a stock database and displays a message box showing the name and component ID of any products that have less in stock than the minimum number allowed.

    The problem is that when i use a message box i can get it to display the name of the components but not the components ID. I used a for loop after the SQL code

    Count = Components_recordset.recordcount
    For counter = 1 to Count
    Msgbox(Components_Record(counter) & " is running low")
    next

    How do i get it to diplay a specific field from the recordset that i looked up?

    Thanks in advance,
    Metaphoric

  2. #2
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974
    you can access fields by name, eg: Components_recordset("componentsID")

    also, you are showing a message for each field, whereas you should be showing a message per record instead, eg:
    VB Code:
    1. Count = Components_recordset.recordcount
    2. For counter = 1 to Count
    3.   Msgbox  Components_recordset("componentsID") & " " & Components_recordset("component_Name")" is running low"
    4.   Components_recordset.movenext
    5. next counter

    alternatively (essentially the same code, just looks different):
    VB Code:
    1. With Components_recordset
    2.   Do While Not (.EOF)
    3.     Msgbox  .Fields("componentsID") & " " & .Fields("component_Name")" is running low"
    4.     .MoveNext
    5.   Loop
    6. End With

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width