Hi,
This my problem.
After distribution of my acces-application I want the new user to be able to enter his Name-adress-etc values, in a one-row table called program-variables. These will be used tot print on reports etc.
I want this to be a one-time event. This will help to avoid illegal re-distibution.
My idea is that before updating the values ther is a check: are the fields null or not?
If not the action should be canceled.
In more general terms the question is: how can I make the programflow in acces condional to the contents of a field in a table?
I'm what you would call an advanced user of Acces, but have little knowledge of VB.
Can anyone give me directions?
6 1437
Hi,
This my problem.
After distribution of my acces-application I want the new user to be able to enter his Name-adress-etc values, in a one-row table called program-variables. These will be used tot print on reports etc.
I want this to be a one-time event. This will help to avoid illegal re-distibution.
My idea is that before updating the values ther is a check: are the fields null or not?
If not the action should be canceled.
In more general terms the question is: how can I make the programflow in acces condional to the contents of a field in a table?
I'm what you would call an advanced user of Access, but have little knowledge of VB.
Can anyone give me directions?
Assuming you have a Form Interface for entering this information, then in the BeforeUpdate() Event of the Form, enter code similar to the following: -
Private Sub Form_BeforeUpdate(Cancel As Integer)
-
If IsNull(Me![txtFirstName]) Then
-
MsgBox "You must enter your First Name"
-
Cancel = True
-
ElseIf IsNull(Me![txtLastName]) Then
-
MsgBox "You must enter your Last Name"
-
Cancel = True
-
ElseIf IsNull(Me![txtAddress]) Then
-
MsgBox "Forgot our Address, did we?"
-
Cancel = True
-
Else
-
'Assuming your Form is not Bound to program-variables
-
Dim MyDB As DAO.Database, MyRS As DAO.Recordset
-
Set MyDB = CurrentDb
-
Set MyRS = MyDB.OpenRecordset("program-variables", dbOpenTable)
-
With MyRS
-
.AddNew
-
MyRS![First Name] = Me![txtFirstName]
-
MyRS![Last Name] = Me![txtLastName]
-
MyRS![Address] = Me![txtAddress]
-
.Update
-
End With
-
MyRS.Close: Set MyRS = Nothing
-
-
MsgBox "Record saved for " & Me![txtFirstName] & " " & Me![txtLastName]
-
End If
-
End Sub
NOTE: Don't forget that you must make provisions to see if the individual has already been added to program-variables before you ever Open this User Info Form. Please be advised that if you have any further questions, I'll be on vacation and will not be able to reply, but I'm sure that we will have many others willing to assist you.
Sorry to answer so late, I was incorrectly under the impression that any answer to my post would by announced by an email.
I'm very glad to recieve such an elaborate answer.
Will look at it first thing tomorrow (its past 00.00 local time now).
Wil let you know what my findings are.
This is not what I was looking for. Probably didn't formulate my question right. I'll try again.
On opening my acces-application, an opening-form is shown with a "start"-button, wich leads to te rest of the application.
However, when the application is not yet been used for the first time, I want the "start"-button to lead to a form where Name-adres-etc values are to be given.
The next time the application is used I do not want this to happen, but I want the "start"-button to lead directly tot the rest of the program. In this way there is only a one-time event in wich the user identify's himself to the program. It is now dedicated to him and is useless to other would-be users.
So, I want the routine in/under the "start"-button to check: Have the fields for name-adres-etc already been filled? Yes: go on to the main program. No: open the name-adres form.
Or, in other words: How do I make the response of button (or another user-driven event) conditional to the contents of a specific field in a table?
Hope I'm more intelligable now?
This is not what I was looking for. Probably didn't formulate my question right. I'll try again.
On opening my acces-application, an opening-form is shown with a "start"-button, wich leads to te rest of the application.
However, when the application is not yet been used for the first time, I want the "start"-button to lead to a form where Name-adres-etc values are to be given.
The next time the application is used I do not want this to happen, but I want the "start"-button to lead directly tot the rest of the program. In this way there is only a one-time event in wich the user identify's himself to the program. It is now dedicated to him and is useless to other would-be users.
So, I want the routine in/under the "start"-button to check: Have the fields for name-adres-etc already been filled? Yes: go on to the main program. No: open the name-adres form.
Or, in other words: How do I make the response of button (or another user-driven event) conditional to the contents of a specific field in a table?
Hope I'm more intelligable now?
The following code, placed in the Click() Event of a Command Button, will check and see if a First Name exists in tblUserInfo. tblUserInfo will consist of a [First], [Last], and [Address] Field all of which are Required, so either it contains a Record or it doesn't. No need to check the existence of all three Fields. If a value exists, open a fictitious Main Form, if it doesn't open a fictitious Name/Address Form. When I have shown you is just simply a broad guideline, more like pseudo code: -
Private Sub cmdStart_Click()
-
On Error GoTo Err_cmdStart_Click
-
-
If IsNull(DLookup("[First]", "tblUserInfo")) Then
-
DoCmd.OpenForm "frmNameAddress", acNormal, , , acFormAdd, acWindowNormal
-
Else
-
DoCmd.OpenForm "frmMainProgram", acNormal, , , acFormEdit, acWindowNormal
-
End If
-
-
Exit_cmdStart_Click:
-
Exit Sub
-
-
Err_cmdStart_Click:
-
MsgBox Err.Description, vbExclamation, "Error in cmdStart_Click()"
-
Resume Exit_cmdStart_Click
-
End Sub
Is this the correct interpretation?
You are the greatest !
May be it's simple to you, but for me its magic.
After changíng the names of the tables etc its works like a swiss clock !
Just proves to me that I should do some serious study of VB...
Thanks.
You are the greatest !
May be it's simple to you, but for me its magic.
After changíng the names of the tables etc its works like a swiss clock !
Just proves to me that I should do some serious study of VB...
Thanks.
Glad it worked out for you.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Agoston Bejo |
last post by:
I want to enforce such a constraint on a column that would ensure that the
values be all unique, but this wouldn't apply to NULL values. (I.e. there
may be more than one NULL value in the column.)...
|
by: Prince Kumar |
last post by:
Is there any way I can define an Unique constraint or unique index
which allows more than one null values for the same column combination
in DB2?
ie, If my index is defined on (col3, col4) where...
|
by: Bob Stearns |
last post by:
I was under the impression that the primary key had to be a unique
index. Since I usually create my primary indices before my primary keys,
in order to get the indices in the same schema as their...
|
by: bwmiller16 |
last post by:
Guys -
I'm doing a database consistency check for a client and I find that
they're building unique indexes for performance/query reasons where
they could be using non-unique indexes.
Note...
|
by: aj |
last post by:
DB2 WSE 8.1 FP5
Red Hat AS 2.1
What is the difference between adding a unique constraint like:
ALTER TABLE <SCHEMA>.<TABLE> ADD CONSTRAINT CC1131378283225 UNIQUE (
<COL1>) ;
and adding a...
|
by: Chris Dunaway |
last post by:
I have a web service which is accessed by a windows forms application.
When the application submits a unit of work (a "job"), I want to return a
job receipt or tracking number back to the...
|
by: Peter Oliphant |
last post by:
Sometimes it's hard to get straight when passing or storing or returning an
instance of a class whether you are still dealing with the original object
or a copy. For example, the '=' operator used...
|
by: Robert Mago |
last post by:
Is there a way to create a 10 characthers or less, alph-numeric string which
is unique. I can't use the guid since its longer then 10 characthers. Also i
cannot use a random number, since being...
|
by: NeoGeo |
last post by:
I have a problem with a SQL SELECT query. As far as my research goes i figured out that UNIQUE is used when you have one column that you whant unique and DISTINCT is used when you have more than one...
|
by: Alvin SIU |
last post by:
Hi all,
I have a table in Db2 v8 like this:
Team Name Role
------ -------- ---------------------
A Superman Leader
A Batman Member
A WonderWoman Member
B ...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| | |