Access 2000 Help Please

  LeadingMNMs 15:08 09 Dec 03
Locked

I am looking for some visual basic code that I can use to open a form in Add Mode, using a button but have been unable to get it to work.

The current code is:

stDocName = "Loans"
DoCmd.OpenForm stDocName, , , stLinkCriteria

I think its something to do with the stLinkCriteria but am not sure.

Any advice welcome. Thanks

  skeletal 16:04 09 Dec 03

You are correct. Replace the stLinkCriteria with -1 (never sure how a post will look, it should be a minus sign then number 1).

Your form should open. By fiddling with the value of stLinkCriteria, you should be able to make the form open in slightly different ways.

Try the -1 trick first, it may be all you need...or at least get you started!

Skeletal

  LeadingMNMs 09:29 10 Dec 03

Hi again, the full visual basic code is:

Private Sub Button1_Click()
On Error GoTo Err_Button1_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "PAYMENTS"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Button1_Click:
Exit Sub

Err_Button1_Click:
MsgBox Err.Description
Resume Exit_Button1_Click

End Sub

any ideas what I should change ?

  LeadingMNMs 09:31 10 Dec 03

sorry some of the formating has been lost on the above post and some parts are on new lines.

  LeadingMNMs 10:27 10 Dec 03

refresh

  LeadingMNMs 21:10 10 Dec 03

refresh again

  skeletal 22:20 10 Dec 03

Sorry I've not been on the site today...and may not make it for another couple of days.

But, did you try the -1 trick? Having said that, I copied your code into Access and it does open a form (I guess because stLinkCriteria is set to something Access doesn't mind when you DIM it).

Also, it is hard to get correct formatting when you do a post, but I assume your DIM statements are on two lines (in the current arrangement, it wont work otherwise).

The stLinkCriteria is used to enter a string representing a SQL expression that will do something to the data underlying the form, so –1 just allows all the data through.

I may be answering the wrong question...sorry!

I’m now not sure what the problem is, but another suggestion: if you want to add to records from the form, are its properties set to "Allow additions" "Yes"? Get to properties by right clicking the very small black square in the small square (!) at the top left of the form in design mode.

If I'm still on the wrong track, perhaps you could explain the problem in more detail.

Skeletal

  LeadingMNMs 07:14 11 Dec 03

if you use a switchboard in access when you open a form you can set it to add mode or edit mode. in add mode the form appears blank (no records are shown) and it edit mode the form shows the records.

there has to be some coding that allows this to happen in a normal form, but i have been unable to find it. i did try the -1 thing but it did not appear to do anything.

thanks for your help

  AccessMoron 18:39 10 Jan 04

try
Private Sub Command0_Click()
DoCmd.OpenForm "MyForm", , , , acFormAdd
End Sub

This thread is now locked and can not be replied to.

Best phone camera 2016/2017: Galaxy S7 vs iPhone 7 vs Google Pixel vs HTC 10 Evo vs OnePlus 3T vs…

1995-2015: How technology has changed the world in 20 years

These are the Best Christmas Ads and Studio Projects of 2016

Super Mario Run preview | Hands-on first impressions of Super Mario Run: Mario's iPhone & iPad…