Topics Search

if-then statement in vba

if-then statement in vba
Views: 7
I have a form called restaurantinfo with a save button on it, and some simple vba behind it. A text box called savedtext appears when it is clicked to show the user that their info has been saved:

Private Sub savebutton_Click()
DoCmd.Save
Me.savedtext.Visible = True
End Sub

How can I make an (if-then) statement that says that if any further changes are made to the info (pulling from table restaurantinfo) on the form, then Me.savedtext.Visible = False ?
Sponsored Links:

More topics

 

Copy SQL statement from query to VBA

Preview
Rather than typing complex query statements into VBA code, developers often mock up a query graphically, switch it to SQL View, copy, and paste into VBA.
If you've done it, you know how messy it is sorting out the quotes, and the line endings.
Learn how to build a form that massages the SQL statement from a query, so it can be pasted into a VBA procedure in Microsoft Access.
 

Case Statement

Preview
This MSAccess tutorial explains how to use the Access Case statement with syntax and examples. The Microsoft Access Case statement can only be used in VBA code. It has the functionality of an IF-THEN-ELSE statement.
 

IF-THEN-ELSE Statement

Preview
This MSAccess tutorial explains how to use the Access IF-THEN-ELSE statement with syntax and examples. The Microsoft Access IF-THEN-ELSE statement can only be used in VBA code.
 

Use a SQL statement to delete data

Preview
Writing SQL to delete data from an MS Access table is just about the easiest SQL statement you can write.
This example will use the SQL statement to create an Access query, but you can use the statement in a macro or VBA as well.
 

Which is better? checking in VBA or SQL

Preview
I currently have a VBA statement that runs SQL to append to a table. I want to first check if there is already a record with the same name in the table to avoid duplicate entries.

Is it best to check before the query is run in the VBA, or in the SQL statement it's self to avoid this problem better?

I'm not sure how I even would check the table with SQL.
 

if-then statement in vba

Preview
I have a form called restaurantinfo with a save button on it, and some simple vba behind it. A text box called savedtext appears when it is clicked to show the user that their info has been saved:

[CODE]

How can I make an (if-then) statement that says that if any further changes are made to the info (pulling from table restaurantinfo) on the form, then Me.savedtext.Visible = False?
 

How would I write a Before UpdateIf Statement

Preview
I need VBA help with an If statement in the before update that would check if txtTitle, txtVWI, cboDepartment, cboVWICategory, cboApprover had data and if so it would set focus to the subform (frmVWISubform) text box (txtStepNumber) and if not then it cancel and exit sub.
 

Msg Dialog Box Prompt

Preview
Request some assistance,

I created a button with the following vba action statement

Private Sub Refreshtxttrig_Click()
DoCmd.RunSQL "drop table [Table Name]"
Exit_CmdImportExcel_Click:
End Sub

(This statement deletes a specific table within access.)

It works well, except when the Table is missing or I accidently click twice, it executes the statement but brings up a "runtime error." instead.

I would like to create a statement that will bring up a MsgBox instead of a runtime error and tells the user that the Table has already been purged
 

Use a control in an SQL statement in Access

Preview
In Access 2003/XP/2000/97, I've created a form where the user enters a value in a textbox. I want to use this value to create an SQL statement. How do I use a control's value in an SQL statement in VBA code?
 

TransferText VBA Import Issue

Preview
I'm trying to a VBA docmd.TransferText statement (properly formatted) to import and append "csv" data to an existing table, e.g.

PHP Code:
DoCmd.TransferTextacImportDelim,"ImportSpecification","tbImportedData",strPathAndFile,vbNo

The VBA code creates a new table with an identical name, while a manual import properly appends the existing table.

Can VBA be used to append an existing table with a TransferText statement