This thread is a bit old, but i was looking to do this as well.
Here's what I found at vb123.com
Sub TestErL()
'This function shows how a line number can be printed out with an error
50 On Error GoTo Err_Wally
100 DoCmd.OpenForm "MyForm"
200 Exit Sub
Err_Wally:
MsgBox "Error line...
If u create a new form bound to your 'SBS' table, with a text box on it bound to your 'Special' field, and say call the new form 'frmSpecial'
Then from your 'Special' button on your main form, do something like this:
sub special_click()
Dim strCrit as string
strCrit = "[sbsID] = " &...
U can also declare the variable at the top of your form code, but only if u want to use the variable on that form only. Otherwise u have to declare it as a global variable.
Dim DebitTot As String
Private Sub SaveClick
DebitTot = DMax(Blah Blah Blah)
End Sub
Private Sub AddNewClick...
Also, you might want to move the docmd.setwarnings true,
...
DoCmd.OpenQuery stDocName12, acNormal, acEdit
Exit_Command6_Click:
DoCmd.SetWarnings true
Exit Sub
Err_Command6_Click:
MsgBox Err.Description
Resume Exit_Command6_Click
End Sub
That way warnings...
You have to add a reference to "Microsoft DAO object Library" in order to use "Dim db as database"
Then make a few changes, mainly your SQL statment,
Private Function AddToList(strTable As String, strField As String, _
strData As String) As Integer
' Add item to table
' Returns acDataErrAdded...
rpadams,
When you open a report, show your custom toolbar,
docmd.showtoolbar "myPrintToolbar", acToolbarYes
and then hide it on the reports close event,
docmd.showtoolbar "myPrintToolbar, acToolbarNo
That should work.
Dave
Elana,
Something like this should work:
Private Sub cmdTest_Click()
For i = 0 To lstTest.ListCount - 1
If lstTest.Column(4, i) = "CA" Then
' Do some stuff
End If
Next i
End Sub
Remember columns and rows in a listbox start at 0.
Dave
If the combobox was bound to the wrong column wouldn't it just not show any Data? For it to be asking for a parameter it has to be a problem with the naming. But then again I could be wrong.:p
Try this anyway:
Go into the query (design mode).
Select the criteria you have in there now and...
Hey Chris,
There's no onPrint event for forms that I know of, but you can use docmd.printout to do the same job. Just put a command button on your form and add the rest of your code after the docmd.printout.
Dave
Private Sub cmdtest_Click()
Dim intErr As Integer
intErr = 0
intErr = testCtls(txtSample1)
intErr = testCtls(txtSample2)
intErr = testCtls(txtSample3)
intErr = testCtls(txtSample4)
If intErr = 0 Then
'perform some stuff
End If
End Sub
Public Function...
Striker,
I have no idea how you would do that!
But, here is a method that will require less code then what you are using.
Private Sub cmdButton1_Click()
Dim ctl As Control
Set ctl = cmdButton1
formatButton ctl
End Sub
Public Sub formatButton (myCtl As Control)
With myCtl...
And if you don't want to use the Hidden System tables, use the AllReports collection as Pat also suggested.
Private Sub Form_Open(Cancel As Integer)
Dim obj As AccessObject, dbs As Object
Dim strReports As String
Set dbs = Application.CurrentProject
For Each obj In...
Sam,
If you want to check the expirey dates when the database is opened, create a macro called "autoexec", which runs code like that which llkhoutx provided.
Dave
Peter,
The code you are using opens the form and then continues to execute the rest of the code in that procedure, therefore your requeries and other code is being executed too early and will not execute again.
If you change:
DoCmd.OpenForm "pupDeleteContactCheck"
to
DoCmd.OpenForm...
Marco,
If you want to run the query in code enter this into the onclick event procedure:
DIM strSQL as string
strSQL = "INSERT INTO Total_List ( [Company#], Company_Name) " & _
"SELECT Selected.SlctCompany, Selected.Slct_Company2 " & _
"FROM Selected"
docmd.runSQL strSQL
If you want to add...
How about this?
Public function repText(strText As String)
Dim strNewText As String
' Replaces all occurences of a single quote with two single quotes
strNewText = Replace(strText, "'", "''", 1, -1, vbTextCompare)
repText = strNewText
End Sub
Dave
Hey Jon, this is straight from a book so I will assume that it works. :p
Sub Editrecords()
' Procedure that edits data
Dim rst As ADODB.Recordset
Dim strSQL As String
On Error GoTo errHandler
'Create the recordset object
Set rst = New ADODB.Recordset
'Write the SQL Statement to return the...