Textbox Data into a table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Gari
    New Member
    • Jan 2007
    • 41

    Textbox Data into a table

    Hello,

    I have a table: tblMinutes
    With the fields: ID, CompName, MinuteDate, MinuteText, NextVisit

    I have a form: frmMinuteNew
    With the textbox: [CompName], [MinuteDate], [MinuteText], [NextVisit]
    All the textbox are UnBound EXCEPT the first one which is bound as follows: =Forms!frmProsp ectDisplayMain! CompName

    The Record Source for frmProspectDisp layMain is tblProspects. frmProspectDisp layMain contains two subforms.

    I have a button on frmProspectDisp layMain. When the user clicks on the button, it opens frmMinuteNew, which has ALL empty fields EXCEPT textbox [CompName]

    I want the user to be able to complete the uncomplete textbox and then save the data by clicking on a button.

    The code I wrote for the recording macro (that saves by clicking on a button) (inspired from a previous work) is as follows:

    Code:
    CurrentDb.Execute "Insert into tblMinutes ( CompName, MinuteDate, MinuteText, NextVisit) values ( " & [Forms]![frmMinuteNew]![CompName] & ", " & [Forms]![frmMinuteNew]![MinuteDate] & ", " & [Forms]![frmMinuteNew]![MinuteText] & ", " & [Forms]![frmMinuteNew]![NextVisit] & ")"
    But it did not work this time…

    I have the message error:

    Syntax error (missing operator) in query expression ‘(here you find the text in [Forms]![frmMinuteNew]![CompName])‘.
    Any idea how to resolve this problem?

    Thank you and best regards.

    G.
  • Gari
    New Member
    • Jan 2007
    • 41

    #2
    Code:
    Dim SQL As String
    
    SQL = "Insert into tblMinutes(CompName, MinuteDate, MinuteText, NextVisit) values ( '" & Me.CompName & "', '" & Me.MinuteDate & "', '" & Me.MinuteText & "', '" & Me.NextVisit & "')"
    CurrentDb.Execute SQL
    This works.....

    Thank you.

    G.

    Comment

    • JustJim
      Recognized Expert Contributor
      • May 2007
      • 407

      #3
      Originally posted by Gari
      This works.....

      Thank you.

      G.
      Isn't it amazing how many times you find the answer yourself because you think about how to state the question? This happens to me all the time!

      Jim

      Comment

      Working...