access database form closes directly when i open it. (1 Viewer)

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
Access database 2007: I have a database with some forms init but when i type my username and password to open the main menu to insert data the form shows 1 second and closes the whole database. I don't know whether the problem is the VB code or the microsoft please help
 

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
ok but how to fix it?
 

spikepl

Eledittingent Beliped
Local time
Today, 16:25
Joined
Nov 3, 2010
Messages
6,144
Comment out code until it doesn't do it any more.

Start with SHIFT pressed to edit code.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:25
Joined
Feb 19, 2013
Messages
16,553
ok but how to fix it?
check your vb code in your login form - comment out any code in which suppresses error messages then put a breakpoint in your code just after the user has entered their name and password (to do this, click on the relevant line and hit the F9 key, a maroon dot will appear and the line will also be highlighted maroon) Go through the login procedure and the code will stop at this point. So step through (hit the F8 button) until you find the problem - it may be in your login form or the form you are trying to open (in which case try looking at the form open, load and current events)
 

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
Run time error 2046
the command Quit is not available
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:25
Joined
Feb 19, 2013
Messages
16,553
this usually means the form is not visible when trying to quit - is it visible when you reach this line?

And clearly, the reason the db is closing is because of docmd.quit so this

DateDiff("d", Me.frm_limt!LIMT, Text51) >= 1650

must be true
 

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
if i send you the link to the database can you check it out?
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:25
Joined
Feb 19, 2013
Messages
16,553
if i send you the link to the database can you check it out?
Sorry, no, I don't have time. You need to sort this for yourself, it is the only way to learn.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:25
Joined
Feb 19, 2013
Messages
16,553
Code:
 this how the code look like i want to learn but i must have a clue
see post #9
 

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
ok.... how to make it True? forgive me iam an accountant Iam not a programmer....thank you
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:25
Joined
Jan 23, 2006
Messages
15,364
Well you're programming now. So what have you done regarding the basics. Put yourself in your accountant hat-- what would you do if a programmer came to you and said --
my bank book doesn't balance?
You'd expect that person to have some concept of arithmetic. Similarly here, we expect you to have a few analytic skills.

For example. to use Datediff(), you could go here to understand the syntax and see an example.

As CJ said, you'll have to do some learning --and don't overlook google to help you find examples.

Have you tried describing the steps you plan on doing in plain English? (eg a specification/plan).
Debugging is a technique you should become familiar with.

Good luck.

Note: You posted while I was typing. You really have to do some research.

A comment at this level
can you tell me please what this 1650 means, I have no Idea why but its working
indicates to me you have done very little research.
How do you know "it" is working? Do you have any idea what the business logic is behind any of this?

Write a paragraph or a few points to identify WHAT you are trying to do in plain English, then repost.

VBA http://www.functionx.com/vbaccess2007/Lesson01.htm
 
Last edited:

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
ya right I'll try to learn some programming codes in the next few days.....thank you
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:25
Joined
Feb 19, 2013
Messages
16,553
Datediff is calculating the differenece between these two values as a number of days - Me.frm_limt!LIMT and Text51

can you tell me please what this 1650 means, I have no Idea why but its working
How are we supposed to know - you wrote the code. All I can say is it approximates to 4.5 years
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:25
Joined
Jan 23, 2006
Messages
15,364
We don't know anything about your database and vba code.
Who created the database? Do you have access to the user manual or the design specifications? Who normally operates the database?
How do you know it's working?????? Or do you mean, it doesn't STOP where it used to?
 

mikiel

Registered User.
Local time
Today, 08:25
Joined
Jan 13, 2015
Messages
23
yes that's what I mean, it doesn't STOP where it used to
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:25
Joined
Jan 23, 2006
Messages
15,364
The code you showed earlier:
Code:
Private Sub Form_Load()
 If DateDiff("d", Me.frm_limt!LIMT, Text51) >= 1650 Then
   DoCmd.Quit
 End If
End Sub

is a private procedure the executes when the Form is Loaded.

The If statement is a conditional statement -- much the same as
if I miss the bus, then I'll be late for the appointment.

The condition (translated to plain English) is
If the number of days "d" between the value in the control LIMT on this form (form name frm_limt ) and the value in the textbox named Text51 on this form is greater than or equal to 1650, then
Quit the application.


If you are an accountant, you are familiar with

IF A is greater than or equal to B, then...do something.

exactly the same concept.

However, 1650 is some value that has significance in your application/environment. There is nothing generic or meaningful in the 1650 to any other situation.
Hopefully this clarifies things.

I must ask again, what exactly is your role in this database?
 

jdraw

Super Moderator
Staff member
Local time
Today, 11:25
Joined
Jan 23, 2006
Messages
15,364
Just for clarity, most production databases (ones which are part of the business... accounts, receivables, inventory) are tested and follow maintenance procedures. They would normally have a current maintenance manual and an operator/user guide. In the case where a user/operator finds a "show stopping error", he/she would report the error to a support/tech team for resolution.
Hope that helps put some of the posts into context.
 

CJ_London

Super Moderator
Staff member
Local time
Today, 15:25
Joined
Feb 19, 2013
Messages
16,553
is it possible that whoever wrote this system does not work for you but has put some code in which prevents the system working after a period of time - in this context 1650 equates to 1650 days or approx. 4.5 years - to encourage you to reemploy him?
 

Users who are viewing this thread

Top Bottom