abelingaw 69 Posting Whiz in Training

Thanks sir, this works.

Uhm yeah, i'm using DevC++ 5.0 (newbie on using this) but use Borland sometimes.

abelingaw 69 Posting Whiz in Training

Already tried that sir. Even the one from Microsoft.

Didn't work.

Don't really know whats wrong here.

abelingaw 69 Posting Whiz in Training

Can you please clarify if your code is for adding data to database.? (I'm such a noob)

Just like the guy above me said, your code doesn't add data to your database.

Your code really is confusing (alignment thingy), please use tabs.

abelingaw 69 Posting Whiz in Training

Using Borland C++ 3.0

Here's my code:

#include<iostream.h>
#include<conio.h>

int main()

{
 int m,d;
 int i=0;

clrscr();

 cout<<"\nEnter Birthday month: ";
 cin>>m;
 cout<<"\nEnter Birthday day: ";
 cin>>d;
 cout<<"\n";


  {
      if(m==3 && d>=21)
       cout<<"ARIES!";
      else if (m==4 && d<=20)
       cout<<"ARIES!";

      else if(m==4 && d>=21)
       cout<<"TAURUS!";
      else if(m==5 && d<=21)
       cout<<"TAURUS!";

      else if(m==5 && d>=22)
       cout<<"GEMINI!";
      else if(m==6 && d<=21)
       cout<<"GEMINI!";

      else if(m==6 && d>=22)
       cout<<"CANCER!";
      else if(m==7 && d<=22)
       cout<<"CANCER!";

      else if(m==7 && d>=23)
       cout<<"LEO!";
      else if(m==8 && d<=21)
       cout<<"LEO!";

      else if(m==8 && d>=22)
       cout<<"VIRGO!";
      else if(m==9 && d<=23)
       cout<<"VIRGO!";

      else if(m==9 && d>=24)
       cout<<"LIBRA!";
      else if(m==10 && d<=23)
       cout<<"LIBRA!";

      else if(m==10 && d>=24)
       cout<<"SCORPIO!";
      else if(m==11 && d<=22)
       cout<<"SCORPIO!";

      else if(m==11 && d>=23)
       cout<<"SAGITTARIUS!";
      else if(m==12 && d<=22)
       cout<<"SAGITTARIUS!";

      else if(m==12 && d>=23)
       cout<<"CAPRICORN!";
      else if(m==1 && d<=20)
       cout<<"CAPRICORN!";

      else if(m==1 && d>=21)
       cout<<"AQUARIUS!";
      else if(m==2 && d<=19)
       cout<<"AQUARIUS!";

      else if(m==2 && d>=20)
       cout<<"PISCES!";
      else if(m==3 && d<=20)
      cout<<"PISCES!";

      else
	cout<<"\nEither day or month value is invalid.";

      gotoxy(35,15);
      cout<<"Try again ? ";

     if(getche()=='y')
     {
	getche();
	i=0;
     } else
     {
	i=1;
     }
     if (i==0)
     {
	gotoxy(45,2);
	cout<<"Enter Birthday month: ";
	cin>>m;
	gotoxy(45,4);
	cout<<"Enter Birthday day: ";
	cin>>d;


   gotoxy(45,6);
     if(m==3 && d>=21)
       cout<<"ARIES!";
     else if (m==4 && d<=20)
       cout<<"ARIES!";

      else if(m==4 && d>=21)
       cout<<"TAURUS!";

      else if(m==5 && d<=21)
       cout<<"TAURUS!";

      else if(m==5 && d>=22)
	  cout<<"GEMINI!";

      else if(m==6 && d<=21)
       cout<<"GEMINI!";

      else if(m==6 && d>=22)
       cout<<"CANCER!";
      else if(m==7 && d<=22)
       cout<<"CANCER!";

      else if(m==7 && d>=23)
       cout<<"LEO!";
      else if(m==8 && d<=21)
       cout<<"LEO!";

      else if(m==8 && d>=22)
       cout<<"VIRGO!";
      else if(m==9 && d<=23)
       cout<<"VIRGO!";

      else …
abelingaw 69 Posting Whiz in Training

Try:

If txtsub.Text = rs2.Fields![subjects] then
       MsgBox "Please enter StudentID!", vbExclamation, "Error"
       txtempno.Text = vbNullString
       txtempno.SetFocus
 End if

Haven't try this but just think of the concept.

If the textbox value is equal to any record on the database (or what column that is)

then the message appears.

abelingaw 69 Posting Whiz in Training

Oh, didn't see that one.:$

abelingaw 69 Posting Whiz in Training

Poster #3 : Please don't bump threads, start your own.

Please mark thread as solved

abelingaw 69 Posting Whiz in Training

You mean, its not showing any records from your database.?

abelingaw 69 Posting Whiz in Training

Hhhmm, i too recieve the error.

Try this:

1. Create a database connection module

Public Dbconn As New ADODB.Connection
Public rs As New ADODB.Recordset

Public Sub createlink()

Dbconn.Provider = "Microsoft Jet 4.0 OLE DB Provider"
Dbconn.Open "EA.mdb"

End Sub

then

2. Replace your code with this:

Dim admissionsql As String          'General Declarations area

Private Sub Form_Load()

Dim db As ADODB.Connection
Dim rs As ADODB.Recordset

Call createlink


Set db = New ADODB.Connection
        db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\EA.mdb"
        
        
Set rs = New ADODB.Recordset
        
        rs.Open "Select * From Admission", Dbconn, adOpenDynamic, adLockOptimistic

End Sub

This code will show all the records in your database in their respective column.

abelingaw 69 Posting Whiz in Training

What line does the error occurs.?

Make sure that all objects seen in your code are present in your form

(e.g DataGrid1).

abelingaw 69 Posting Whiz in Training

Please give more information about your problem.

abelingaw 69 Posting Whiz in Training

Try:

Modified code from sir Andre

Do while not rs.EOF = true
    
    Set list = ListView1.ListItems.Add , , rs.Fields!("RecordNumber")
    lista.ListItems(lista.ListItems.Count).SubItems(1) = rs.Fields!("Firstname")
    lista.ListItems(lista.ListItems.Count).SubItems(2) = rs.Fields!("Lastname")
    lista.ListItems(lista.ListItems.Count).SubItems(3) = rs.Fields!("Birthdate")

    rs.MoveNext
    Loop

Is that lista or list.? Confuses me.

Just change to list if not lista.

abelingaw 69 Posting Whiz in Training
abelingaw 69 Posting Whiz in Training

I'm having this problem regarding my Backup code.

I get an error saying "Permission Denied".

Here's my code:

Public Sub DBBackup()

Dim fsys As New FileSystemObject
Dim myfile As File


Dim isTrue As String
Dim isFalse As String

Set myfile = fsys.GetFile(App.Path & "\Database.mdb")


'Create Backup folder if not present
If fsys.FolderExists(App.Path & "\Backup") = False Then
    fsys.CreateFolder App.Path & "\Backup"
    
End If

isTrue = App.Path & "/Backup/" & Format$(Date, "yyyy-mm-dd")

'Replace file if existing
If fsys.FileExists(isTrue) = True Then
    fsys.DeleteFile isTrue
End If


'Start Backup Process
If myfile.Attributes = ReadOnly And myfile.ParentFolder.Attributes = ReadOnly Then
    myfile.Attributes = Normal And myfile.ParentFolder.Attributes = Normal
    
fsys.CopyFile (App.Path & "\Database.mdb"), App.Path & "\Backup", False

End If

MsgBox "Database Backup Process Complete", vbInformation, "Information"


Set fsys = Nothing

Form2.Enabled = True
Unload Me

End Sub

I don't know if it is the code or it has something to do with file/folder attributes specifically Read Only attrib.

My Database file "Database.mdb" has no set attribute's, but the folder where i want to create a backup file of my Database is set to Read Only and also the folder that contains my whole project (Includes Both of Backup folder and program).

I tried removing the Read Only attrib but it returns as soon as i look at its attrib again.

Note: i am log on as Admin on my PC

abelingaw 69 Posting Whiz in Training


To restore a file, you need to have another backup in a different file. When deleted, just copy the file over from the different folder and it should be replaced.

I'm going to use Filecopy on that one.

Thanks again sir.

abelingaw 69 Posting Whiz in Training

I suggest you use use a full version rather than a portable.

Portables doesn't contain all features of the VB App (Full),

which may be the problem.

Use the full version. Google it

abelingaw 69 Posting Whiz in Training

Try this:

Dim con as new ADODB.Connection
Dim rs As New ADODB.Recordset 


If txtSEARCH.Text = vbNullString Then
  MsgBox " The search field is empty.", vbExclamation 	'Change message if you want
  txtSERACH.SetFocus
End If

With rs

    If .State = adStateOpen Then .Close

    'TABLENAME - replace with your table name 
    'txtSEARCH - replace: name of your textbox where you enter the
    'patient name of the patient that records you want 
    
    .Open "Select * from TABLENAME where NAME =" & txtSEARCH.Text & ";", con, adOpenKeyset, adLockPessimistic
    
    
    Do While .EOF = False
    
    With Form5		'Change Form5 to the name of the form which to be loaded on click
    

    'Change "NAME" and "AGE" with your own Table Column names
    'from the table where the records are located 
    'Arrange them according to where textbox the records would be displayed

    .txtNAME.Text = rs.Fields("NAME").Value
    .txtAGE.Text = rs.Fields("AGE").Value
    .txtROOM.Text = rs.Fields("Roomnumber").Value
           

    End With

   .MoveNext
   Loop
  
  .Close

Form5.Show	'Change Form5 to the name of the form which to be loaded on click

Put this code on a Command Button - Click Event

Hope this helps :)

abelingaw 69 Posting Whiz in Training

No sir. What i mean is my whole database would have a backup to a folder Named "Backup"

The folder is also located in the same folder where my program is.

Nah, Biometrics isn't included here, just like saying about it ;)

The backup file extension name is '.bak'

Just don't know how to restore and delete a .bak file

RESTORE - i mean a backup file from previous day can be restored today
DELETE - as in delete the file, cant be restored again.

If you can give some attachment.

abelingaw 69 Posting Whiz in Training

And please be more clean in stating (writing) your problem.

If you may.

abelingaw 69 Posting Whiz in Training

You mean showing records from your Database to a form.?

Try using Listview.

Heres a sample:

Public Sub Init_Data()

'On Error GoTo err:

    If rs.State = adStateOpen Then rs.Close	
    lvlEmpInfo.ListItems.Clear			'lvlEmpinfo - name of the Listview
    

rs.Open "Select * from Tablename", Dbconn, adOpenKeyset, adLockPessimistic	'Dbconn is my Database connection
    

    Do While rs.EOF = False
    
    lvlEmpInfo.ListItems.Add , , rs.Fields("EmpID").Value		

	
    'Subitems(1), the (1) is the arrangement of columns from 
    'DOnt know if you have to start from 0 really
    'The ("Fields") is where you put the column name from your database
	
    
    lvlEmpInfo.ListItems(lvlEmpInfo.ListItems.Count).SubItems(1) = rs.Fields("Field1").Value
    lvlEmpInfo.ListItems(lvlEmpInfo.ListItems.Count).SubItems(2) = rs.Fields("Field2").Value
    lvlEmpInfo.ListItems(lvlEmpInfo.ListItems.Count).SubItems(3) = rs.Fields("Field3").Value
    
    rs.MoveNext
    Loop
    
    If lvlEmpInfo.ListItems.Count = 0 Then		'Condition if there are no records from database
        cmdDelete.Enabled = False
        cmdEdit.Enabled = False
        cmdPrintSel.Enabled = False
        cmdPrintAll.Enabled = False
    Else
        cmdPrintAll.Enabled = True
    End If
    
    Dbconn.Close
    
    Exit Sub
err:
    MsgBox err.Description, vbCritical, "Error"
    Set rs = Nothing
End Sub

You can then just call this sub in your form load event.

Private Sub Form_Load()

Call Init_Data  'You can just remove the 'Call' word, still the same
  
End Sub

Or you could use Datagrid:

http://www.vbtutor.net/lesson26.html


Hope this helps.

abelingaw 69 Posting Whiz in Training

yes sir, didn't work.

But fix already.

My mistake was using MS Windows Common Controls 5.0 and 6.0 at the same time.

Fix by removing 5.0. Haha, I'm such a noob.

Replies are appreciated, THanks.

AndreRet commented: Well done... +4
abelingaw 69 Posting Whiz in Training

OK, i have this Backup module for my system's database.

Now i would like to have a module of restoring and deleting backups of it.

Here's some info:

The backup files created are stored in a Folder named "Backup"

My database has 2 Columns having OLE type objects, Pictures and Fingerprints
from a Biometrics (This part isn't finish yet)

Can you help me with this, code snippet if any.

Googled but codes from other sites is complicated (VERY)

So if you can provide some code snippet, please include some comment lines for instruction.

Thanks.

abelingaw 69 Posting Whiz in Training

Hhhmmm, this one is making me crazy now.

Can't really make it work.

abelingaw 69 Posting Whiz in Training

Waaahhh, just google it bro..

MegaUpload is making me mad.

abelingaw 69 Posting Whiz in Training

Crap.

Connection unstable.

Error

abelingaw 69 Posting Whiz in Training

Hhhmm.

I think it has something to do with Timer.

Set its interval and when it reaches the limit,

like in every 3 minutes, it will do the saving function.

I don't know code for that though, you can just google codes for the Timer.

I am noob in networking ^_^

abelingaw 69 Posting Whiz in Training

Please mark thread as Solve..

Thanks

AndreRet commented: First solution, well done! +4
abelingaw 69 Posting Whiz in Training

Try this.

Private Sub cmdSave_Click()

On Error Resume Next


If txtDate.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtDate.SetFocus: Exit Sub
If cmbTitle.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": cmbTitle.SetFocus: Exit Sub
If txtName.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtName.SetFocus: Exit Sub
If txtIc.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtIc.SetFocus: Exit Sub
If txtEmail.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtEmail.SetFocus: Exit Sub
If txtPhone.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtPhone.SetFocus: Exit Sub
If txtAddress.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtAddress.SetFocus: Exit Sub
If txtAddress1.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtAddress1.SetFocus: Exit Sub
If cmbResidential.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": cmbResidential.SetFocus: Exit Sub
If cmbGender.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": cmbGender.SetFocus: Exit Sub
If cmbNumber.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": cmbNumber.SetFocus: Exit Sub
If txtRental.Text = "" Then MsgBox "Insufficient Data.", vbInformation, "Information": txtRental.SetFocus: Exit Sub



Adodc1.Recordset.AddNew

Adodc1.Recordset!Dateregistration = txtDate.Text
Adodc1.Recordset!Title = cmbTitle.Text
Adodc1.Recordset!Name = txtName.Text
Adodc1.Recordset!Ic = txtIc.Text
Adodc1.Recordset!Email = txtEmail.Text
Adodc1.Recordset!Phonenumber = txtPhone.Text
Adodc1.Recordset!Address = txtAddress.Text
Adodc1.Recordset!Address1 = txtAddress1.Text
Adodc1.Recordset!Residential = cmbResidential.Text
Adodc1.Recordset!Gender = cmbGender.Text
Adodc1.Recordset!Numberofrooms = cmbNumber.Text
Adodc1.Recordset!Rentalprices = txtRental.Text

Adodc1.Recordset.Update
MsgBox "Successfuly Save!!!", vbInformation

End Sub

You can change the message for each entity, such as for txtEmail,

the message can be "Field empty. Please Enter Email address!"

abelingaw 69 Posting Whiz in Training

Currently uploading for you and other users.

Just an hour, my connection's a little bit slow

abelingaw 69 Posting Whiz in Training

Your welcom brotha.

Please mark thread as solve if your problem was solved.

Start new thread if you have another concern.

abelingaw 69 Posting Whiz in Training

My fault.

Change End If on Line 20 with End With

abelingaw 69 Posting Whiz in Training

Ok i have this form used for registering user for my program (User and Admin type)

When i run it, i get an error that says "Invalid Property Value"

This is my code for my GetUsers function called on my Form_Load event

Public Sub GetUsers()

'    On Error GoTo eh
Call con
        
    Set rs = New ADODB.Recordset

    With rs
        If .State = adStateOpen Then .Close
        
        .Open "Select * From Users Order By UserName;", Dbconn, adOpenKeyset, adLockOptimistic
        
        If rs.EOF = True Then
            lvwUser.ListItems.Clear
            Exit Sub
            
        End If
        
        lvwUser.ListItems.Clear
        Do While .EOF = False
            lvwUser.ListItems.Add , , .Fields("ID")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(2) = .Fields("UserName")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("Password")
           'lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("UserType")
            .MoveNext
        Loop
    End With


    Exit Sub
    
eh:
    MsgBox err.Description, vbCritical


End Sub

This is where i am getting the error.

Do While .EOF = False
            lvwUser.ListItems.Add , , .Fields("ID")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(2) = .Fields("UserName")
            lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("Password")
           'lvwUser.ListItems(lvwUser.ListItems.Count).SubItems(3) = .Fields("UserType")
            .MoveNext
        Loop

I fix it using this code:

ListView1.ListItems.Add , , rs!ID
 ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , rs!UserName
 ListView1.ListItems.Item(ListView1.ListItems.Count).ListSubItems.Add , , rs!Password
    rs.MoveNext

It does fix it but when i reRun my program, there are no records on my listview control

even if i have three records on my database.

I am using a Listview control and view is Report.

Code of my listview:

Private Sub lvwUser_ItemClick(ByVal Item As MSComctlLib.ListItem)

On Error GoTo err
    Set rs = New ADODB.Recordset

    With rs
    
        If .State = adStateOpen Then .Close
      
        
              .Open "SELECT * FROM Users where ID = '" & lvwUser.SelectedItem.Text, Dbconn, adOpenKeyset, …
abelingaw 69 Posting Whiz in Training

Is this VB (4,5,6) or VBA (dont really know what is VBA ;)

I think there's no code as "Insert Into" in VB ( at line 10).

Looks like Php to me.

Try this:

Dim rs as New ADODB.Recordset

With rs

.Open "select * from Pemilik", Dbconn, adOpenDynamic, adLockOptimistic
        
        .AddNew
            
      

            .Fields(1) = txtNa.Text	'you can also put the name of the field in your table inside the ()
            .Fields(2) = txtNokad.Text	'i prefer using numbers for easy coding
            .Fields(3) = txtWarganegara.Text
            .Fields(4) = Notel.Text
	    .Fields(1) = txtHarga.Text
            .Fields(2) = txtTingkat.Text

            
            
        .Update
            MsgBox "Record successfully saved!!", vbInformation
        
            .Close

End If

And concatenation in VB if you are going to put 2 or more textbox values in a single field in your Database:

.Fields(1) = .Fields(1) = txtNa.Text & " " & txtNokad.Text & " " & txtWarganegara.Text

Hope this helps.

abelingaw 69 Posting Whiz in Training

This is funny.

The mistake was on my other php code or html file that is.

The arrangement of fields wasn't correct.

Sorry though.

abelingaw 69 Posting Whiz in Training

You can also add this code to alert a user before closing a (any) form.

Private Sub Form_Unload(Cancel As Integer)

Dim strMess
If LogOff = False Then

    strMess = "You are about to close the Automated Payroll System." & vbCrLf & vbCrLf & "Are you sure?"
    
    If MsgBox(strMess, vbQuestion + vbYesNo, "Exit Confirmation") = vbYes Then
        End
        
    Else
        
        Cancel = 1
        
    End If
    
ElseIf LogOff = True Then

    Unload Me
    Form1.Show
    
End If

End Sub

Please mark thread as solved.

abelingaw 69 Posting Whiz in Training

I've fix it.

Uhm thanks for the replies though.

Please dont hijack

abelingaw 69 Posting Whiz in Training

Thanks so much.

I'm lazy in creating reports, REALLY.

//SOLVED

abelingaw 69 Posting Whiz in Training

Well it is B.

My script and statements are correct.

Hhhm dont know whats wrong.

abelingaw 69 Posting Whiz in Training

Regarding my previous post:

http://www.daniweb.com/forums/thread326976.html

I manage to correct that error.

Now my problem is the misplacement of records on my fields.

Records that suppose to be in the Region field now displays at the Name field.
Records that should be on the Zipcode field now at the Age field.
Records that should be on CPnumber field now displays at the Birthday field.

It does displays the record though.
Just dont know why i have this misplacement error in displaying the fields.

<html>
<head>
<title>Record Entry</title>
</head>

<body>

<center>

<br><br>
<br><br>
<br><br>
<br><br>


<b>
<?php

// $sample = isset($_POST['sample']) ? $_POST["sample"] : "";

	$fname=isset($_POST['fname']) ? $_POST["fname"] : "";
	$age=isset($_POST['age']) ? $_POST["age"] : "";
	$birthday=isset($_POST['birthday']) ? $_POST["birthday"] : "";
	

	$address=isset($_POST['address']) ? $_POST["address"] : "";
	$status=isset($_POST['status']) ? $_POST["status"] : "";
	$religion=isset($_POST['religion']) ? $_POST["religion"] : "";
	$region=isset($_POST['region']) ? $_POST["region"] : "";
	$zipcode=isset($_POST['zipcode']) ? $_POST["zipcode"] : "";
	$cpnumber=isset($_POST['cpnumber']) ? $_POST["cpnumber"] : "";

$con = mysql_connect('localhost', 'root' , '');
	
if (! $con)
	{
die(mysql_error());
	}
mysql_select_db("database" , $con) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO Record (Name, Age, Birthday, Address, Status, Religion, Region, ZipCode, CPNumber) VALUES (
		
'$fname',
'$age', 
'$birthday',
'$address', 
'$status',
'$religion', 
'$region',
'$zipcode', 
'$cpnumber')") or die("Insert Error: ".mysql_error());
mysql_close($con);

/* Database Connection Ends */



print "Record successfully added.";
?>


<br><br>
<form method="POST" action="Insertform.php">
<input type="submit" value="Insert Another Record">
</form>
<br><br>

<form method="POST" action="index.php">
<input type="submit" value="Back to Main Menu">
</form>

</center>
</body>
</html>
abelingaw 69 Posting Whiz in Training

Oh now i get it.

I have to use ISSET.

$fname=isset($_POST['fname']) ? $_POST["fname"] : "";
	$age=isset($_POST['age']) ? $_POST["age"] : "";
	$birthday=isset($_POST['birthday']) ? $_POST["birthday"] : "";
	

	$address=isset($_POST['address']) ? $_POST["address"] : "";
	$status=isset($_POST['status']) ? $_POST["status"] : "";
	$religion=isset($_POST['religion']) ? $_POST["religion"] : "";
	$region=isset($_POST['region']) ? $_POST["region"] : "";
	$zipcode=isset($_POST['zipcode']) ? $_POST["zipcode"] : "";
	$cpnumber=isset($_POST['cpnumber']) ? $_POST["cpnumber"] : "";

$con = mysql_connect('localhost', 'root' , '');

//TO MODS
//POST READY FOR DELETION

abelingaw 69 Posting Whiz in Training

Ok, im having a long time creating reports for my program.

I would like to ask if it is possible to connect my program

to an existing msword file.

E.g:

If i click a button on my form, lets say cmdLeaveReport,

an msword file named leavereport.doc will open (of course in word window that is)

Is it possible, any example.?

Only a report, not connected to my Dbase at all.

abelingaw 69 Posting Whiz in Training

I finally got it.

User = cWords(txtUser.Text)
                    CurrentPosition = rs.Fields("UserType")
                                                
                    With Form2
                    
                    .StatusBar.Panels(2).Text = User
                    
                        If rs.Fields("UserType").Value = "Admin" Then
                            
                            .Toolbar1.Enabled = True
                        
                        Else
                            
                            .Toolbar1.Enabled = False
                            
                            .mnuNewEmp.Enabled = False
                            .mnuCpayroll.Enabled = False
                            .mnuEmpinfo.Enabled = False
                            .mnuEmpdtr.Enabled = False
                            .mnuPayslip.Enabled = False
                            .mnuBackup.Enabled = False
                            .mnuRestore.Enabled = False
                            .mnuUreg.Enabled = False
     
                        End If
                              
                        
                            End With
                        Unload Me
                        Form2.Show

Thanks again sir.

//SOLVED

AndreRet commented: Well done! +4
abelingaw 69 Posting Whiz in Training

I think this is normal.

Maybe the vars aren't properly set. (?)

COuld u modify my code.

Im a starter and im only at GET and POST method right now

abelingaw 69 Posting Whiz in Training

Here are the errors im getting.

Notice: Undefined index: address in C:\wamp\www\Insertrecord.php on line 24

Notice: Undefined index: status in C:\wamp\www\Insertrecord.php on line 25

Notice: Undefined index: religion in C:\wamp\www\Insertrecord.php on line 26

Notice: Undefined index: region in C:\wamp\www\Insertrecord.php on line 27

Notice: Undefined index: zipcode in C:\wamp\www\Insertrecord.php on line 28

Notice: Undefined index: cpnumber in C:\wamp\www\Insertrecord.php on line 29
Insert Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'Code, CP Number) VALUES ( '', '', '', '', '', '', '', '', '')' at line 1

Heres my code:

<html>
<head>
<title>Record Entry</title>
</head>

<body>

<center>

<br><br>
<br><br>
<br><br>
<br><br>


<b>
<?php

/* Variables Here */

$fname=$_POST['fname'];
$age=$_POST['age'];
$birthday=$_POST['birthday'];
$address=$_POST['address'];
$status=$_POST['status'];
$religion=$_POST['religion'];
$region=$_POST['region'];
$zipcode=$_POST['zipcode'];
$cpnumber=$_POST['cpnumber'];

/* Database Connection Start */

$con = mysql_connect('localhost', 'root' , '');
	
if (! $con)
	{
die(mysql_error());
	}
mysql_select_db("database" , $con) or die("Select Error: ".mysql_error());
$result=mysql_query("INSERT INTO Record (Name, Age, Birthday, Address, Status, Religion, Region, Zip Code, CP Number) VALUES (
'$fname',
'$age', 
'$birthday',
'$address', 
'$status',
'$religion', 
'$region',
'$zipcode', 
'$cpnumber')") or die("Insert Error: ".mysql_error());
mysql_close($con);

/* Database Connection Ends */

print "Record successfully added.";
?>
<br><br>
<form method="POST" action="Insertform.php">
<input type="submit" value="Insert Another Record">
</form>
<br><br>

<form method="POST" action="index.php">
<input type="submit" value="Back to Main Menu">
</form>

</center>
</body>
</html>

My Fields are right. I just don't get it, the first 3 $_POST are correct.

abelingaw 69 Posting Whiz in Training

Thanks for that sir.

Uhm i can hardly explain this one.

I only want to disable the toolbar and menubar

if a user account is used to log in.

And if admin account, all is enabled.

Lets say, in my Dbase, i have 3 fields,

Usertype, Username and Password.

Under Username, i have 'sample' as a username to login and its Usertype is 'User'.

How do i apply the disabling code if a user type account is used.

How will i do that (with Dbase connection)

Same for the Admin type.

abelingaw 69 Posting Whiz in Training

Ok here's what i want to do.

I woul like to disable the toolbar and menubar in my main form
depending on the usertype that was logged in.

My dbase field is UserType and record type can only be
User and Admin (Depends on the registration).

When a user log in which is a "User" type, toolbar and menubar is disabled.
If it is an admin type, they are enabled.

Oh, the user type is also displayed on my statusbar ("panel(2)").

Code for Main (form_load)

Private Sub Form_Load()

If StatusBar.Panels(2).Text = User Then
    Toolbar1.Enabled = False
Else
    Toolbar1.Enabled = True
End If

End Sub

For the login form:

Private Sub cmdLogin_Click()

Dim User As String
Dim CurrentPosition As String

passattemp = passattemp + 1
    
If txtUser.Text = "" And txtPass.Text = "" Then
    
    
    MsgBox "Data required, please enter a valid username and password!", vbInformation, "Log-in Error"
            
            txtUser.Text = ""
            txtPass.Text = ""
            txtUser.SetFocus
 Else
    
 
    Set db = New ADODB.Connection
        db.CursorLocation = adUseClient
        db.Open "PROVIDER=Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "\Database.mdb"
    
    Set rs = New ADODB.Recordset
        rs.Open "select * from Users where UserName = '" & txtUser & "'", db, adOpenStatic, adLockOptimistic

            
                    
If Not rs.EOF Then
        

    If txtPass.Text = rs!Password Then
    MsgBox "Welcome to The Provincial Capitol Payroll System!", vbInformation, "Log-in Form"
    
    
                    User = cWords(txtUser.Text)
                    CurrentPosition = rs.Fields("UserType")
                                                
                    With Form2
                            .StatusBar.Panels(2).Text = User
                              
                        End With
                        Unload Me
                        Form2.Show
    
        Else
              MsgBox "Password Incorrect. Please enter a valid password!" & vbCrLf & " …
abelingaw 69 Posting Whiz in Training

Now thats fast.. Thanks sir.

Uhm im such a newbie

abelingaw 69 Posting Whiz in Training
<html>
<head>
<title>Records</title>
</head>

<body>

<?php

$fname=$_POST['fname'];
$age=$_POST['age'];
$birthday=$_POST['birthday'];


$con = mysql_connect('localhost', 'root' , '');
	
if (! $con)
	{
die(mysql_error());
mysql_select_db("database" , $con) or die("Select Error: ".mysql_error());
	}	
$result=mysql_query("INSERT INTO Record (Name, Age, Birthday) VALUES (
'$fname',
'$age', 
'$birthday')") or die("Insert Error: ".mysql_error());
mysql_close($link);
print "Record added";
?>
<form method="POST" action="birthdays_insert_form.php">
<input type="submit" value="Insert Another Record">
</form>
<br>

<form method="POST" action="birthdays_dbase_interface.php">
<input type="submit" value="Dbase Interface">
</form>



</body>
</html>
abelingaw 69 Posting Whiz in Training

Really need someone to fix my program ( i mean the whole thing ).

abelingaw 69 Posting Whiz in Training
Enum Connect
    useAdo = 1
    useDao = 2
End Enum



Dim DataFile As Integer, FileLength As Long, Chunks As Integer
Dim SmallChunks As Integer, Chunk() As Byte, i As Integer
Const ChunkSize As Integer = 1024
Public PhotoFileName As String
Public Event OnPhotoSaving(Succeded As Boolean, Filename As String)
Public Event OnPhotoLoading(IsPicture As Boolean, ErrorDescription As String)
'Public Event Click()
Const m_def_ConnectionType = 1
Dim m_ConnectionType As Connect
'Event Declarations:
Event Click() 'MappingInfo=Photo,Photo,-1,Click


Public Sub Reset()
    '---------------------------------------------
    'Clear the Photo picture box
    '---------------------------------------------
    Photo.Picture = LoadPicture("")
End Sub

Public Sub Refresh()
    '---------------------------------------------
    'Load the current imagefile into the picture box
    '---------------------------------------------
    If Len(PhotoFileName) > 0 Then Photo.Picture = LoadPicture(PhotoFileName)
End Sub

Public Function OpenPhotoFile() As String
Dim Filter As String
Dim Filename As String
'On error GoTo Out
    '---------------------------------------------
    'Open a common dialog whitout ocx to browse
    'for an image file
    '---------------------------------------------

    Filter = "Pictures(*.bmp;*.ico;*.gif;*.jpg)|*.bmp;*.ico;*.gif;*.jpg|All Files (*.*)|*.*"
    PhotoFileName = OpenFile(Filter, "Select Photo Image", App.Path)
    OpenPhotoFile = PhotoFileName
    Photo.Picture = LoadPicture(PhotoFileName)
Exit Function
Out:
    MsgBox err.Description
End Function

Public Sub SavePhoto(Fieldname As Field)
Dim rs As Recordset
'On error GoTo Out

'---------------------------------------------
' If there is no image file exits
'---------------------------------------------
If Len(PhotoFileName) = 0 Then Exit Sub
DataFile = 1

'---------------------------------------------
'Open the image file
'---------------------------------------------
Open PhotoFileName For Binary Access Read As DataFile
    FileLength = LOF(DataFile)    ' Length of data in file
    '---------------------------------------------
    'If the imagefile is empty exits
    '---------------------------------------------
    If FileLength = 0 Then
        Close DataFile
        Exit Sub
    End If
    '---------------------------------------------
    'Calculate the bytes(Chunks)pakages to write
    '---------------------------------------------
    Chunks …