Author Topic: Questions in Access 2007  (Read 2618 times)

0 Members and 1 Guest are viewing this topic.

Offline Shiw Liang

  • Avast Evangelist
  • Super Poster
  • ***
  • Posts: 1435
Questions in Access 2007
« on: May 28, 2011, 03:00:11 PM »
Hey guys,

I've been creating a sort of program in Microsoft Access 2007 and the program is working quite well but I don't know how to limit the values in table design...
Can you guys please show me how to?

Like Member ID(Number): It should be limited from 1 to 99999 (5 digits maximum)

Phone Number(Number): It should be limited to 7 digits [Not less or more digit(s)]

Concerning the date format: It is MM/DD/YY and I want to change it to DD/MM/YY but I don't seem to know how to :(
« Last Edit: May 28, 2011, 03:12:26 PM by Shiw Liang »

DarkMasters

  • Guest
Re: Questions in Access 2007
« Reply #1 on: May 29, 2011, 10:54:28 PM »
If you familiar with VBS then it would be easy. I think there's some options in field properties to set limitation in field value. I never make a program with Access but I know that Access using the same language and a limited function of Visual Basic programming language.

When I'm doing database programming, I always put any rule or limitation like what you've describe in my code rather than field properties of my database.

Offline Shiw Liang

  • Avast Evangelist
  • Super Poster
  • ***
  • Posts: 1435
Re: Questions in Access 2007
« Reply #2 on: May 30, 2011, 11:37:46 AM »
Well my teacher said that there is no need to use Visual Basic programming language since this is not for our level yet...(Next year learning it if computer sub is optional)

Erm...Can teach me how to limit it using the VB language ^^?

DarkMasters

  • Guest
Re: Questions in Access 2007
« Reply #3 on: May 30, 2011, 12:22:47 PM »
Well, your teacher is right. What I'm saying is Ms. Access is using the same language and a limited function of VB, I think the syntax is quite the same when you're creating macro with Word or Excel.

I think you could create such limitation when you're designing form for your database in Access.
e.g. You're creating a textbox which named TxtMemberID which linked to your Member ID field in your database the simple syntax for limiting the entry would be like this :

Private Sub TxtMemberID_Validate(Cancel as Boolean)
    If TxtMemberID.Text < 1 Or TxtMemberID.Text > 99999 Then
        MsgBox ("Error. The accepted value must be between 1 to 99999")
        Cancel = True
    End If
End Sub

The syntax I describe above is a simple example of how VB language written. Of course you can use other graceful method of limiting data entry by using other means like string function (Str), etc.

I can't give you precise example because I'm not using and installing Ms. Office in my machine nor do I've ever doing VB Database Programming with Access (I'm using SQL Server as database).

Offline Shiw Liang

  • Avast Evangelist
  • Super Poster
  • ***
  • Posts: 1435
Re: Questions in Access 2007
« Reply #4 on: May 30, 2011, 12:40:37 PM »
Ahh ok...What you've just written seem like a peusodo code I think
Like an algorithm like...If....Then...
                         Endif   ^^

DarkMasters

  • Guest
Re: Questions in Access 2007
« Reply #5 on: May 30, 2011, 01:02:42 PM »
Ahh ok...What you've just written seem like a peusodo code I think
Like an algorithm like...If....Then...
                         Endif   ^^

Well, that's what VB is. An Object Oriented Programming language. Basically all programming language are just the same. It uses the same algorithm though using a different syntax or methods.

Offline Shiw Liang

  • Avast Evangelist
  • Super Poster
  • ***
  • Posts: 1435
Re: Questions in Access 2007
« Reply #6 on: May 30, 2011, 01:21:50 PM »
I guess I should ask my teacher for further details what to do with my program...

DarkMasters

  • Guest
Re: Questions in Access 2007
« Reply #7 on: May 30, 2011, 01:34:56 PM »
Yup. You should do that.

But, I think it's not much different than my example above since Ms. Office is using VBScript for their macro language.

Offline Shiw Liang

  • Avast Evangelist
  • Super Poster
  • ***
  • Posts: 1435
Re: Questions in Access 2007
« Reply #8 on: May 30, 2011, 01:51:11 PM »
Ahh!
Thank you for answering :)