How To Get Access To Forget About the Past?

viperbyte

Registered User.
Local time
Today, 14:48
Joined
Oct 1, 2011
Messages
12
I wrote a routine that causes input boxes to popup and that was not my intention. I think the following line is what caused that:
'cmdSQLInsert.CommandText = "Insert Into Table1(ID, NAME1, AGE) Values(?,?,?)"

I don't need the input boxes and finally wrote this thing to work like I want. But now the input boxes still keep popping up. I deleted the whole routine that had the ?,?,? line in it and yet the input boxes keep showing up. I'm thinking that something causes this to keep being remembered and needs to be deleted or something like that. Anyone know what I'm talking about and can tell me how to get rid of the popup input boxes? Please.
 
I wrote a routine that causes input boxes to popup and that was not my intention. I think the following line is what caused that:
'cmdSQLInsert.CommandText = "Insert Into Table1(ID, NAME1, AGE) Values(?,?,?)"

I don't need the input boxes and finally wrote this thing to work like I want. But now the input boxes still keep popping up. I deleted the whole routine that had the ?,?,? line in it and yet the input boxes keep showing up. I'm thinking that something causes this to keep being remembered and needs to be deleted or something like that. Anyone know what I'm talking about and can tell me how to get rid of the popup input boxes? Please.

Since the issue occurs in VB code, it could be an issue with the last Compile of the code. Compile the code again and seee if there are any errors that you are not aware of. If the issue is related to that, fix the problems and the problem should go away. If the problem still does not go away, then you will need to show more of the VB Procedure or Function that contained the line in question.
 
The problem didn't go away after compiling. So I opened a copy of the database that has never seen the problematic code that was well behaving. In that copy I added the following code and the now the same thing is happening that I get two input boxes one after the other. One says enter NAME and the other say enter NAME1 which aren't even mentioned in the program at all.

Code:
Private Sub Command0_Click()
  Dim deleteAll As String
  deleteAll = "DELETE * FROM Table1"
  DoCmd.SetWarnings False
  DoCmd.RunSQL deleteAll
  DoCmd.SetWarnings True
    
  Dim MySQL As String
  Dim openTempSql As String
    
  Dim cnn1 As ADODB.Connection
  Dim MyRecordSet As New ADODB.Recordset
  Set cnn1 = CurrentProject.Connection
  MyRecordSet.ActiveConnection = cnn1
  
  MySQL = "SELECT [Inventory Master].Description, [Inventory Master].Brand, [Inventory Master].[Special Order Item], [Inventory Master].[Vendor Item Number], [Inventory Master].[Item Key], [Inventory Master].Par, [Vendor Master].[Vendor Key], [Vendor Master].[Vendor Name], [Vendor Sales Items].[PO Number], [Vendor Sales Items].[Qty Ordered], [Vendor Sales Items].[Vendor Key], [Vendor Sales Orders].[PO Number], [Vendor Sales Orders].Status, [Vendor Sales Orders].[Received Date], [Back Orders].ID, [Back Orders].[Customer Key], [Back Orders].[BO Quantity], [Back Orders].[Order Date], [Back Orders].[Item Key], [Vendor Sales Orders].[Vendor Delivery Date]"
  MySQL = MySQL + " FROM (([Inventory Master] INNER JOIN [Vendor Master] ON [Inventory Master].[Vendor Key]=[Vendor Master].[Vendor Key]) INNER JOIN ([Vendor Sales Items] INNER JOIN [Vendor Sales Orders] ON [Vendor Sales Items].[PO Number]=[Vendor Sales Orders].[PO Number]) ON ([Vendor Master].[Vendor Key]=[Vendor Sales Items].[Vendor Key]) AND ([Inventory Master].[Item Key]=[Vendor Sales Items].[Item Key]) AND ([Vendor Master].[Vendor Key]=[Vendor Sales Orders].[Vendor Key])) LEFT JOIN [Back Orders] ON [Inventory Master].[Item Key]=[Back Orders].[Item Key]"
  MySQL = MySQL + " WHERE ((([Inventory Master].[Special Order Item]) = True) And (([Inventory Master].[Vendor Delivery Date]) = #8/30/2011#) And (([Inventory Master].Par) = 0) And (([Vendor Sales Orders].Status) = 'Placed') And (([Vendor Sales Orders].[Vendor Delivery Date]) = #8/30/2011#)) "
  MySQL = MySQL + " ORDER BY [Vendor Master].[Vendor Name], [Vendor Sales Items].[PO Number]"
  
  MyRecordSet.Open MySQL, , adOpenDynamic, adLockOptimistic
  
  Do Until MyRecordSet.EOF
     If MyRecordSet.EOF Then
        MyRecordSet.MoveLast
     End If
     
     Call InsertInTemp(MyRecordSet.Fields(0).Value, MyRecordSet.Fields(1).Value, "bla bla bla")
          
     MyRecordSet.MoveNext
  Loop
  MyRecordSet.Close
  cnn1.Close
  
  '''''''''''''''''''''''
 Dim MyReport As Report
 DoCmd.OpenReport "LabelsTable1", acViewDesign, , , acWindowNormal
 Set MyReport = Reports![LabelsTable1]
 MySQL = "SELECT ID, NAME, AGE FROM Table1"
 MyReport.RecordSource = MySQL
 DoCmd.Close acReport, "LabelsTable1", acSaveYes
 
 'To preview and not print paper
 DoCmd.OpenReport "LabelsTable1", acViewPreview, , , acWindowNormal
 
 'to print labels
 'DoCmd.OpenReport "LabelsTable1", acViewNormal, , , acWindowNormal
  
End Sub
Sub InsertInTemp(ByVal first As String, ByVal second As String, ByVal third As String)
Dim InsertRecord As String
InsertRecord = "Insert Into Table1(ID, NAME1, AGE) Values('" + first + "','" + second + "','" + third + "')"
  DoCmd.SetWarnings False
  DoCmd.RunSQL InsertRecord
  DoCmd.SetWarnings True
End Sub
 
Both are mentioned:

MySQL = "SELECT ID, NAME, AGE FROM Table1"

InsertRecord = "Insert Into Table1(ID, NAME1, AGE) Values(...

If those aren't field names in the table, they will throw parameter prompts. Even if "Name" is a field name, you likely need to bracket it since it's a reserved word.
 
Yes both are mentioned. My brain is mush. I found the problem. NAME1 is one of the fields in Labels in the label report and that was a problem. I changed it to firstname and put firstname in the sql statements and the paramater input boxes went away. Thanks everyone for looking it over :)
 
Glad you got it sorted out.
 

Users who are viewing this thread

Back
Top Bottom