Re: updating to a table

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Rick Brandt (rickbrandt2_at_hotmail.com)
Date: 02/17/05


Date: Thu, 17 Feb 2005 06:47:09 -0600


"Jimenda" <Jimenda@discussions.microsoft.com> wrote in message
news:F20BCE45-85A4-48E8-A4A2-7B06871ABABB@microsoft.com...
>I have a form that has 7 combo boxes, I would like to be able to make a
> selection in each box (if no selection made, then default or null), and then
> click on a button and have the selected items in each combo box to update/add
> 7 separate fields on a new line of a separate table. If anyone can help I
> would appreciate it. I already have the combos setup and can select a value
> in each combo. I am just not sure how to have a button cause all of the info
> to update a table.
> --
> Thank You & God Bless,
>
> Jimenda

The basic method is...

dim SQL as string

SQL = "INSERT INTO TableName " & _
            "(Field1, Field2, Field3, etc...) " & _
            "VALUES(" & Me.NumericComboBox & ", '" & _
            "Me.TextComboBox & "', #" & _
            "Me.DateComboBox & "#, etc...)"

Debug.Print SQL
'CurrentDB.Execute SQL, dbFailOnError

The challenge is in getting a string built up that results in a valid SQL
statement with all the proper delimiters, spaces, and If-then handling to
account for the Null values you want if a ComboBox is left blank.

That is why I include the Debug.Print line and have the execute statement
commented out. What you should do is tweak your code, try the code and then
examine the SQL string that is sent to the immediate window. This can be
examined to see if it is structured as you expected and can even be pasted into
a query to see if it has any errors and works as expected.

Once you have the code creating a correct statement you can comment out the
Debug.Print line and remove the comment from the execute line.

-- 
I don't check the Email account attached
to this message.     Send instead to...
RBrandt    at       Hunter      dot      com
 


Relevant Pages

  • Re: Syntax of SQL in VB
    ... >a combo box based on a selection in another combo box. ... I choose Honda in one combo box and Honda models ... is in the use of quotation marks to fit the SQL ... the entire SQL is a string and must be within quotation marks. ...
    (microsoft.public.access.queries)
  • Injecting a variable attribute from a select grid control
    ... I'm very new to asp.net and very green with programming in general. ... an individual can make a selection from a data grid view. ... variable into SQL string, which is a attached to a SQLDataSource ... success in taking the value of the selection, placing it into the SQL ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Multiple checkbox Query
    ... selected from multiple checkboxes on the Web form. ... I am using the string in a ASP page with the SQL statement: ... This works fine with one checkbox selection, ...
    (microsoft.public.sqlserver.programming)
  • Re: Using combo box selection to supply criteria for query
    ... Sorry, I am still learning SQL and VBA, I don't think that I made the ... The form contains 5 combo boxes; SBT Account, Region, ADM, Month, Year ... If I only make a selection in the Region combo box ... Post the query SQL. ...
    (microsoft.public.access.forms)
  • Re: SQL RPGLE cursor delete from view? -204
    ... how does the SQL engine know which rowto delete? ... C/exec sql ... i have a huge select statement joining 6 files, with some selection ... C+ fetch PRIOR from C1 into:f1, ...
    (comp.sys.ibm.as400.misc)