Hi!
I'm totally beginer in VB and I try to build a project but i got stucked.
I want to open a form from other form and when this new form will open I want to be able to already add data for the database.
I know the code to add a new data is
datStock.RecordSet.AddNew
Is this a code I can use on the new form because when I open the form I get the first record of the datStock and I want to have the empty fiels to be able to add the new data.
Can some one help me?
Thanks.
adding record modehow to open a subform in adding mode
Page 1 of 1
5 Replies - 1414 Views - Last Post: 24 October 2008 - 07:28 AM
Replies To: adding record mode
#2
Re: adding record mode
Posted 21 October 2008 - 03:59 PM
pls post your code here to solve your problem
#3
Re: adding record mode
Posted 23 October 2008 - 01:50 PM
flintso, on 21 Oct, 2008 - 12:58 PM, said:
Hi!
I'm totally beginer in VB and I try to build a project but i got stucked.
I want to open a form from other form and when this new form will open I want to be able to already add data for the database.
I know the code to add a new data is
datStock.RecordSet.AddNew
Is this a code I can use on the new form because when I open the form I get the first record of the datStock and I want to have the empty fiels to be able to add the new data.
Can some one help me?
Thanks.
I'm totally beginer in VB and I try to build a project but i got stucked.
I want to open a form from other form and when this new form will open I want to be able to already add data for the database.
I know the code to add a new data is
datStock.RecordSet.AddNew
Is this a code I can use on the new form because when I open the form I get the first record of the datStock and I want to have the empty fiels to be able to add the new data.
Can some one help me?
Thanks.
Here is the code for the subform.
Actually it is a basic form but i want that instead using the cmdNewRecord the subform to open in adding mode.
Database is the well known Biblio from Microsoft.
Private Sub cmdDeleteRecord_Click()
On Error GoTo Delete_Error
If MsgBox("Are you sure you want to delete this record?", _
vbQuestion + vbYesNo + vbDefaultButton2, _
"Confirm") = vbNo Then
Exit Sub
End If
'delete the current record
DatAuthors.Recordset.Delete
'move to a valid record
CmdMoveNext_Click
Exit Sub
Delete_Error:
'This error will occur if you atempt to delete an author that is related to
'another table in the biblio.mdb database ...
MsgBox "This record cannot be deleted. Error code = " _
& Err.Number & vbCrLf & Err.Description, _
vbCritical, "Cannot delete"
End Sub
Private Sub CmdMoveFirst_Click()
DatAuthors.Recordset.MoveFirst
End Sub
Private Sub CmdMoveLast_Click()
DatAuthors.Recordset.MoveLast
End Sub
Private Sub CmdMoveNext_Click()
DatAuthors.Recordset.MoveNext
If DatAuthors.Recordset.EOF = True Then
DatAuthors.Recordset.MoveLast
End If
End Sub
Private Sub CmdMovePrevious_Click()
DatAuthors.Recordset.MovePrevious
If DatAuthors.Recordset.BOF = True Then
DatAuthors.Recordset.MoveFirst
End If
End Sub
Private Sub CmdNewRecord_Click()
DatAuthors.Recordset.AddNew
cmdSaveRecord.Enabled = True
CmdMoveFirst.Enabled = False
CmdMoveLast.Enabled = False
CmdMovePrevious.Enabled = False
CmdMoveNext.Enabled = False
cmdDeleteRecord.Enabled = False
CmdNewRecord.Enabled = False
End Sub
Private Sub cmdSaveRecord_Click()
DatAuthors.Recordset.Update
cmdSaveRecord.Enabled = False
CmdMoveFirst.Enabled = True
CmdMoveLast.Enabled = True
CmdMovePrevious.Enabled = True
CmdMoveNext.Enabled = True
cmdDeleteRecord.Enabled = True
CmdNewRecord.Enabled = True
End Sub
Thank you!
Mod Edit: Please use code tags when posting your code. Code tags are used like so =>
Thanks,
PsychoCoder
#4
Re: adding record mode
Posted 23 October 2008 - 06:14 PM
good thing where did you view your record most probably you should add your record there
better you don't need to create a sub form use a panel or frame to solve this problem
better you don't need to create a sub form use a panel or frame to solve this problem
#5
Re: adding record mode
Posted 24 October 2008 - 06:32 AM
thava, on 23 Oct, 2008 - 06:14 PM, said:
good thing where did you view your record most probably you should add your record there
better you don't need to create a sub form use a panel or frame to solve this problem
better you don't need to create a sub form use a panel or frame to solve this problem
Thank you for your answer but now i'm complete lost because i don't know how to do this.
I searched on the net and here on the tutorials but i find only info about VB.net or for access :-( and i have VB 6.
Could you help me please?
Thanks!
#6
Re: adding record mode
Posted 24 October 2008 - 07:28 AM
ok ,
Drag and drop a frame control in your form set the visible property to false
now add the textboxes
now set the datasource and datafield property
when you click on the add new button just make the frame visible property to true and enter the record values in the textboxes
when you want to save the record just call
DatAuthors.Recordset.update that's all you save the record now make the frame visible property false
and amke a another frame for show the records with a flexgrid or MSHFLEXGRID according to your datasource
i think you get the required form
Drag and drop a frame control in your form set the visible property to false
now add the textboxes
now set the datasource and datafield property
when you click on the add new button just make the frame visible property to true and enter the record values in the textboxes
when you want to save the record just call
DatAuthors.Recordset.update that's all you save the record now make the frame visible property false
and amke a another frame for show the records with a flexgrid or MSHFLEXGRID according to your datasource
i think you get the required form
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote



|