473,394 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Unique, one-time data, programflow in Acces

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?
Mar 1 '08 #1
6 1437
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_BeforeUpdate(Cancel As Integer)
  2. If IsNull(Me![txtFirstName]) Then
  3.   MsgBox "You must enter your First Name"
  4.     Cancel = True
  5. ElseIf IsNull(Me![txtLastName]) Then
  6.   MsgBox "You must enter your Last Name"
  7.     Cancel = True
  8. ElseIf IsNull(Me![txtAddress]) Then
  9.   MsgBox "Forgot our Address, did we?"
  10.     Cancel = True
  11. Else
  12.   'Assuming your Form is not Bound to program-variables
  13.   Dim MyDB As DAO.Database, MyRS As DAO.Recordset
  14.   Set MyDB = CurrentDb
  15.   Set MyRS = MyDB.OpenRecordset("program-variables", dbOpenTable)
  16.     With MyRS
  17.       .AddNew
  18.         MyRS![First Name] = Me![txtFirstName]
  19.         MyRS![Last Name] = Me![txtLastName]
  20.         MyRS![Address] = Me![txtAddress]
  21.       .Update
  22.     End With
  23.   MyRS.Close: Set MyRS = Nothing
  24.  
  25.   MsgBox "Record saved for " & Me![txtFirstName] & " " & Me![txtLastName]
  26. End If
  27. 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.
Mar 2 '08 #2
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.
Mar 4 '08 #3
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?
Mar 5 '08 #4
ADezii
8,834 Expert 8TB
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:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdStart_Click()
  2. On Error GoTo Err_cmdStart_Click
  3.  
  4. If IsNull(DLookup("[First]", "tblUserInfo")) Then
  5.   DoCmd.OpenForm "frmNameAddress", acNormal, , , acFormAdd, acWindowNormal
  6. Else
  7.   DoCmd.OpenForm "frmMainProgram", acNormal, , , acFormEdit, acWindowNormal
  8. End If
  9.  
  10. Exit_cmdStart_Click:
  11.   Exit Sub
  12.  
  13. Err_cmdStart_Click:
  14.   MsgBox Err.Description, vbExclamation, "Error in cmdStart_Click()"
  15.   Resume Exit_cmdStart_Click
  16. End Sub
Is this the correct interpretation?
Mar 6 '08 #5
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.
Mar 6 '08 #6
ADezii
8,834 Expert 8TB
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.
Mar 6 '08 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

26
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.)...
3
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...
6
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...
4
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...
5
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...
2
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...
2
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...
9
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...
0
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...
6
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 ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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
0
BarryA
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...
1
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...
0
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...
0
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...
0
Oralloy
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,...
0
tracyyun
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.